Skip to contents

A subclass of WrappedModel. It is created

  • if you set the respective option in configureMlr - when a model internally crashed during training. The model always predicts NAs.

The if mlr option on.error.dump is TRUE, the FailureModel contains the debug trace of the error. It can be accessed with getFailureModelDump and inspected with debugger.

Its encapsulated learner.model is simply a string: The error message that was generated when the model crashed. The following code shows how to access the message.

See also

Examples

configureMlr(on.learner.error = "warn")
data = iris
data$newfeat = 1 # will make LDA crash
task = makeClassifTask(data = data, target = "Species")
m = train("classif.lda", task) # LDA crashed, but mlr catches this
#> Warning: Could not train learner classif.lda: Error in lda.default(x, grouping, ...) : 
#>   variable 5 appears to be constant within groups
print(m)
#> Model for learner.id=classif.lda; learner.class=classif.lda
#> Trained on: task.id = data; obs = 150; features = 5
#> Hyperparameters: 
#> Training failed: Error in lda.default(x, grouping, ...) : 
#>   variable 5 appears to be constant within groups
#> 
#> Training failed: Error in lda.default(x, grouping, ...) : 
#>   variable 5 appears to be constant within groups
#> 
print(m$learner.model) # the error message
#> [1] "Error in lda.default(x, grouping, ...) : \n  variable 5 appears to be constant within groups\n"
p = predict(m, task) # this will predict NAs
print(p)
#> Prediction: 150 observations
#> predict.type: response
#> threshold: 
#> time: NA
#>   id  truth response
#> 1  1 setosa     <NA>
#> 2  2 setosa     <NA>
#> 3  3 setosa     <NA>
#> 4  4 setosa     <NA>
#> 5  5 setosa     <NA>
#> 6  6 setosa     <NA>
#> ... (#rows: 150, #cols: 3)
print(performance(p))
#> mmce 
#>   NA 
configureMlr(on.learner.error = "stop")