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/basics.html#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'
# 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
#>
#> $selected.terms
#> [1] 1 8 12
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 11.72574
#>
#> $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 1 0 0 0 0 0 0
#> [3,] 0 0 0 -1 0 0 0 0 0 0
#> [4,] 0 1 0 0 0 0 0 0 0 0
#> [5,] 0 -1 0 0 0 0 0 0 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 1 0 0 0
#> [9,] 0 0 0 0 0 0 -1 0 0 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 0 0 0 0 1
#> [13,] 0 0 0 0 0 0 0 0 0 -1
#> [14,] 0 0 0 0 0 0 0 1 0 0
#> [15,] 0 0 0 0 0 0 0 -1 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 71.1 0.00 0 0 0.0 0 0.000
#> [3,] 0 0 0 71.1 0.00 0 0 0.0 0 0.000
#> [4,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [5,] 0 1 0 0.0 0.00 0 0 0.0 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 52 0.0 0 0.000
#> [9,] 0 0 0 0.0 0.00 0 52 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 0 0 0.0 0 1.615
#> [13,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [14,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#> [15,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] -2.89262248
#> [2,] -0.62796862
#> [3,] 0.37273710
#> [4,] -3.39059956
#> [5,] -0.39384545
#> [6,] 0.08156062
#> [7,] -0.12295904
#> [8,] -0.87237707
#> [9,] 0.13377581
#> [10,] 4.87748866
#> [11,] 5.16337098
#> [12,] 0.68485303
#> [13,] 5.47342178
#> [14,] -3.47748954
#> [15,] -4.29508015
#> [16,] -0.54770000
#> [17,] 2.14195527
#> [18,] -0.27251345
#> [19,] 0.72823814
#> [20,] -0.72695716
#> [21,] -2.03728887
#>
#> $fitted.values
#> [,1]
#> [1,] 23.892622
#> [2,] 22.027969
#> [3,] 18.327263
#> [4,] 21.490600
#> [5,] 14.693845
#> [6,] 24.318439
#> [7,] 22.922959
#> [8,] 11.272377
#> [9,] 10.266224
#> [10,] 9.822511
#> [11,] 27.236629
#> [12,] 29.715147
#> [13,] 28.426578
#> [14,] 24.977490
#> [15,] 19.495080
#> [16,] 13.847700
#> [17,] 17.058045
#> [18,] 26.272513
#> [19,] 15.071762
#> [20,] 20.426957
#> [21,] 23.437289
#>
#> $lenb
#> [1] 15
#>
#> $coefficients
#> [,1]
#> [1,] 29.71514697
#> [2,] -0.04608592
#> [3,] -3.13387202
#>
#> $x
#> [,1] [,2] [,3]
#> [1,] 1 58 1.005
#> [2,] 1 58 1.600
#> [3,] 1 123 1.825
#> [4,] 1 53 1.845
#> [5,] 1 193 1.955
#> [6,] 1 10 1.575
#> [7,] 1 43 1.535
#> [8,] 1 153 3.635
#> [9,] 1 163 3.809
#> [10,] 1 178 3.730
#> [11,] 1 14 0.585
#> [12,] 1 0 0.000
#> [13,] 1 13 0.220
#> [14,] 1 45 0.850
#> [15,] 1 98 1.820
#> [16,] 1 193 2.225
#> [17,] 1 123 2.230
#> [18,] 1 39 0.525
#> [19,] 1 212 1.555
#> [20,] 1 123 1.155
#> [21,] 1 57 1.165
#>
#> 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
#> 6.652599