Multivariate Adaptive Regression Splines.
Calls mda::mars() from mda.
Meta Information
Task type: “regr”
Predict Types: “response”
Feature Types: “integer”, “numeric”
Required Packages: mlr3, mlr3extralearners, mda
Parameters
| Id | Type | Default | Levels | Range |
| degree | integer | 1 | \([1, \infty)\) | |
| nk | integer | - | \([1, \infty)\) | |
| penalty | numeric | 2 | \([0, \infty)\) | |
| thresh | numeric | 0.001 | \([0, \infty)\) | |
| prune | logical | TRUE | TRUE, FALSE | - |
| trace.mars | logical | FALSE | TRUE, FALSE | - |
| forward.step | logical | FALSE | TRUE, FALSE | - |
References
Friedman, H J (1991). “Multivariate adaptive regression splines.” The annals of statistics, 19(1), 1–67.
See also
as.data.table(mlr_learners)for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html#sec-learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrMars
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$format()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$print()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3::LearnerRegr$predict_newdata_fast()
Examples
# Define the Learner
learner = lrn("regr.mars")
print(learner)
#>
#> ── <LearnerRegrMars> (regr.mars): Multivariate Adaptive Regression Splines ─────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3extralearners, and mda
#> • Predict Types: [response]
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties:
#> • Other settings: use_weights = 'error', predict_raw = 'FALSE'
# Define a Task
task = tsk("mtcars")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
print(learner$model)
#> $call
#> mda::mars(x = x, y = y)
#>
#> $all.terms
#> [1] 1 2 4 6 8 10 12 14 16 18
#>
#> $selected.terms
#> [1] 1 6 8 10
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 7.370629
#>
#> $factor
#> am carb cyl disp drat gear hp qsec vs wt
#> [1,] 0 0 0 0 0 0 0 0 0 0
#> [2,] 0 0 0 0 0 0 0 0 0 1
#> [3,] 0 0 0 0 0 0 0 0 0 -1
#> [4,] 0 0 1 0 0 0 0 0 0 0
#> [5,] 0 0 -1 0 0 0 0 0 0 0
#> [6,] 0 1 0 0 0 0 0 0 0 0
#> [7,] 0 -1 0 0 0 0 0 0 0 0
#> [8,] 0 0 0 0 1 0 0 0 0 0
#> [9,] 0 0 0 0 -1 0 0 0 0 0
#> [10,] 0 0 0 0 0 1 0 0 0 0
#> [11,] 0 0 0 0 0 -1 0 0 0 0
#> [12,] 0 0 0 0 0 0 1 0 0 0
#> [13,] 0 0 0 0 0 0 -1 0 0 0
#> [14,] 0 0 0 0 0 0 0 1 0 0
#> [15,] 0 0 0 0 0 0 0 -1 0 0
#> [16,] 1 0 0 0 0 0 0 0 0 0
#> [17,] -1 0 0 0 0 0 0 0 0 0
#> [18,] 0 0 0 1 0 0 0 0 0 0
#> [19,] 0 0 0 -1 0 0 0 0 0 0
#>
#> $cuts
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [2,] 0 0 0 0.0 0.00 0 0 0.0 0 1.513
#> [3,] 0 0 0 0.0 0.00 0 0 0.0 0 1.513
#> [4,] 0 0 4 0.0 0.00 0 0 0.0 0 0.000
#> [5,] 0 0 4 0.0 0.00 0 0 0.0 0 0.000
#> [6,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [7,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [8,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [9,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [10,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#> [11,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#> [12,] 0 0 0 0.0 0.00 0 52 0.0 0 0.000
#> [13,] 0 0 0 0.0 0.00 0 52 0.0 0 0.000
#> [14,] 0 0 0 0.0 0.00 0 0 14.6 0 0.000
#> [15,] 0 0 0 0.0 0.00 0 0 14.6 0 0.000
#> [16,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [17,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [18,] 0 0 0 75.7 0.00 0 0 0.0 0 0.000
#> [19,] 0 0 0 75.7 0.00 0 0 0.0 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] 0.54228158
#> [2,] 0.54228158
#> [3,] -4.54252971
#> [4,] 1.37251382
#> [5,] -0.06699931
#> [6,] 0.04113480
#> [7,] -2.45551032
#> [8,] -1.33568756
#> [9,] 1.74430176
#> [10,] 2.64430176
#> [11,] 0.54430176
#> [12,] -1.35000286
#> [13,] -1.62289486
#> [14,] 4.16082516
#> [15,] 1.20704803
#> [16,] -0.30708792
#> [17,] -1.56876852
#> [18,] -0.93917484
#> [19,] 0.80304604
#> [20,] 0.12746013
#> [21,] 0.45915946
#>
#> $fitted.values
#> [,1]
#> [1,] 20.45772
#> [2,] 20.45772
#> [3,] 27.34253
#> [4,] 17.32749
#> [5,] 18.16700
#> [6,] 24.35887
#> [7,] 25.25551
#> [8,] 20.53569
#> [9,] 14.65570
#> [10,] 14.65570
#> [11,] 14.65570
#> [12,] 11.75000
#> [13,] 12.02289
#> [14,] 28.23917
#> [15,] 29.19295
#> [16,] 15.80709
#> [17,] 14.86877
#> [18,] 28.23917
#> [19,] 29.59695
#> [20,] 19.57254
#> [21,] 14.54084
#>
#> $lenb
#> [1] 19
#>
#> $coefficients
#> [,1]
#> [1,] 18.166999
#> [2,] -2.359911
#> [3,] 3.898457
#> [4,] 4.926212
#>
#> $x
#> [,1] [,2] [,3] [,4]
#> [1,] 1 3 1.14 1
#> [2,] 1 3 1.14 1
#> [3,] 1 0 1.09 1
#> [4,] 1 1 0.39 0
#> [5,] 1 0 0.00 0
#> [6,] 1 1 0.93 1
#> [7,] 1 1 1.16 1
#> [8,] 1 3 1.16 1
#> [9,] 1 2 0.31 0
#> [10,] 1 2 0.31 0
#> [11,] 1 2 0.31 0
#> [12,] 1 3 0.17 0
#> [13,] 1 3 0.24 0
#> [14,] 1 0 1.32 1
#> [15,] 1 1 2.17 1
#> [16,] 1 1 0.00 0
#> [17,] 1 3 0.97 0
#> [18,] 1 0 1.32 1
#> [19,] 1 1 1.01 2
#> [20,] 1 5 0.86 2
#> [21,] 1 7 0.78 2
#>
#> attr(,"class")
#> [1] "mars"
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> regr.mse
#> 20.78537