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 2 4
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 6.68298
#>
#> $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 0 0 0 0 0 1 0 0
#> [5,] 0 0 0 0 0 0 0 -1 0 0
#> [6,] 1 0 0 0 0 0 0 0 0 0
#> [7,] -1 0 0 0 0 0 0 0 0 0
#> [8,] 0 0 0 0 0 0 0 0 1 0
#> [9,] 0 0 0 0 0 0 0 0 -1 0
#> [10,] 0 0 0 0 1 0 0 0 0 0
#> [11,] 0 0 0 0 -1 0 0 0 0 0
#> [12,] 0 0 0 0 0 1 0 0 0 0
#> [13,] 0 0 0 0 0 -1 0 0 0 0
#> [14,] 0 0 1 0 0 0 0 0 0 0
#> [15,] 0 0 -1 0 0 0 0 0 0 0
#> [16,] 0 0 0 1 0 0 0 0 0 0
#> [17,] 0 0 0 -1 0 0 0 0 0 0
#> [18,] 0 1 0 0 0 0 0 0 0 0
#> [19,] 0 -1 0 0 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.615
#> [3,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [4,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#> [5,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#> [6,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [7,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [8,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [9,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [10,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [11,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [12,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#> [13,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#> [14,] 0 0 4 0.0 0.00 0 0 0.0 0 0.000
#> [15,] 0 0 4 0.0 0.00 0 0 0.0 0 0.000
#> [16,] 0 0 0 71.1 0.00 0 0 0.0 0 0.000
#> [17,] 0 0 0 71.1 0.00 0 0 0.0 0 0.000
#> [18,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [19,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] -0.6067962
#> [2,] 0.2534422
#> [3,] 1.1791894
#> [4,] -2.4219861
#> [5,] 2.5672825
#> [6,] 0.4335391
#> [7,] -1.5503595
#> [8,] 2.0673178
#> [9,] 2.1669435
#> [10,] 1.1127386
#> [11,] 4.5122239
#> [12,] -4.4368934
#> [13,] -1.4230352
#> [14,] -2.6215341
#> [15,] -0.3950124
#> [16,] -0.5498609
#> [17,] 1.4488399
#> [18,] -0.7932641
#> [19,] -0.1254321
#> [20,] 0.5684232
#> [21,] -1.3857663
#>
#> $fitted.values
#> [,1]
#> [1,] 21.606796
#> [2,] 21.146558
#> [3,] 17.520811
#> [4,] 20.521986
#> [5,] 21.832718
#> [6,] 18.766461
#> [7,] 19.350359
#> [8,] 14.332682
#> [9,] 8.233057
#> [10,] 29.287261
#> [11,] 29.387776
#> [12,] 25.936893
#> [13,] 16.923035
#> [14,] 17.821534
#> [15,] 13.695012
#> [16,] 27.849861
#> [17,] 24.551160
#> [18,] 16.593264
#> [19,] 19.825432
#> [20,] 14.431577
#> [21,] 22.785766
#>
#> $lenb
#> [1] 19
#>
#> $coefficients
#> [,1]
#> [1,] 25.3751410
#> [2,] -5.6475093
#> [3,] 0.9731643
#>
#> $x
#> [,1] [,2] [,3]
#> [1,] 1 1.005 1.96
#> [2,] 1 1.600 4.94
#> [3,] 1 1.825 2.52
#> [4,] 1 1.845 5.72
#> [5,] 1 1.575 5.50
#> [6,] 1 1.825 3.80
#> [7,] 1 1.825 4.40
#> [8,] 1 2.455 2.90
#> [9,] 1 3.635 3.48
#> [10,] 1 0.000 4.02
#> [11,] 1 0.220 5.40
#> [12,] 1 0.850 5.51
#> [13,] 1 1.905 2.37
#> [14,] 1 1.820 2.80
#> [15,] 1 2.225 0.91
#> [16,] 1 0.320 4.40
#> [17,] 1 0.525 2.20
#> [18,] 1 1.555 0.00
#> [19,] 1 1.155 1.00
#> [20,] 1 1.955 0.10
#> [21,] 1 1.165 4.10
#>
#> 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
#> 12.39006