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 16
#>
#> $selected.terms
#> [1] 1 4 12
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 13.32945
#>
#> $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 1 0 0 0 0 0 0 0
#> [3,] 0 0 -1 0 0 0 0 0 0 0
#> [4,] 0 0 0 0 0 0 0 0 0 1
#> [5,] 0 0 0 0 0 0 0 0 0 -1
#> [6,] 0 0 0 0 0 0 1 0 0 0
#> [7,] 0 0 0 0 0 0 -1 0 0 0
#> [8,] 1 0 0 0 0 0 0 0 0 0
#> [9,] -1 0 0 0 0 0 0 0 0 0
#> [10,] 0 0 0 1 0 0 0 0 0 0
#> [11,] 0 0 0 -1 0 0 0 0 0 0
#> [12,] 0 0 0 0 0 0 0 1 0 0
#> [13,] 0 0 0 0 0 0 0 -1 0 0
#> [14,] 0 0 0 0 0 0 0 0 1 0
#> [15,] 0 0 0 0 0 0 0 0 -1 0
#> [16,] 0 1 0 0 0 0 0 0 0 0
#> [17,] 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 0 0 0.0 0 0.000
#> [2,] 0 0 4 0.0 0 0 0 0.0 0 0.000
#> [3,] 0 0 4 0.0 0 0 0 0.0 0 0.000
#> [4,] 0 0 0 0.0 0 0 0 0.0 0 1.513
#> [5,] 0 0 0 0.0 0 0 0 0.0 0 1.513
#> [6,] 0 0 0 0.0 0 0 52 0.0 0 0.000
#> [7,] 0 0 0 0.0 0 0 52 0.0 0 0.000
#> [8,] 0 0 0 0.0 0 0 0 0.0 0 0.000
#> [9,] 0 0 0 0.0 0 0 0 0.0 0 0.000
#> [10,] 0 0 0 71.1 0 0 0 0.0 0 0.000
#> [11,] 0 0 0 71.1 0 0 0 0.0 0 0.000
#> [12,] 0 0 0 0.0 0 0 0 14.5 0 0.000
#> [13,] 0 0 0 0.0 0 0 0 14.5 0 0.000
#> [14,] 0 0 0 0.0 0 0 0 0.0 0 0.000
#> [15,] 0 0 0 0.0 0 0 0 0.0 0 0.000
#> [16,] 0 1 0 0.0 0 0 0 0.0 0 0.000
#> [17,] 0 1 0 0.0 0 0 0 0.0 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] -0.2639916
#> [2,] -0.3225252
#> [3,] -2.1533030
#> [4,] -2.5149988
#> [5,] -0.2539840
#> [6,] -2.1606782
#> [7,] 6.2233164
#> [8,] 5.2404156
#> [9,] 1.0142303
#> [10,] 4.3919224
#> [11,] -4.7540201
#> [12,] -2.1860736
#> [13,] -3.3424526
#> [14,] 3.0769729
#> [15,] -0.7370034
#> [16,] 1.1194252
#> [17,] 1.9905200
#> [18,] -1.5277385
#> [19,] -0.6975064
#> [20,] -0.2899645
#> [21,] -1.8525631
#>
#> $fitted.values
#> [,1]
#> [1,] 21.263992
#> [2,] 21.722525
#> [3,] 16.453303
#> [4,] 25.314999
#> [5,] 19.453984
#> [6,] 17.360678
#> [7,] 8.476684
#> [8,] 27.159584
#> [9,] 29.385770
#> [10,] 29.508078
#> [11,] 26.254020
#> [12,] 17.686074
#> [13,] 18.542453
#> [14,] 16.123027
#> [15,] 28.037003
#> [16,] 24.880575
#> [17,] 28.409480
#> [18,] 17.327738
#> [19,] 20.397506
#> [20,] 15.289964
#> [21,] 23.252563
#>
#> $lenb
#> [1] 17
#>
#> $coefficients
#> [,1]
#> [1,] 26.1578569
#> [2,] -5.3289792
#> [3,] 0.9381763
#>
#> $x
#> [,1] [,2] [,3]
#> [1,] 1 1.362 2.52
#> [2,] 1 1.702 4.94
#> [3,] 1 2.057 1.34
#> [4,] 1 1.637 8.40
#> [5,] 1 1.927 3.80
#> [6,] 1 2.267 3.50
#> [7,] 1 3.832 2.92
#> [8,] 1 0.687 4.97
#> [9,] 1 0.102 4.02
#> [10,] 1 0.322 5.40
#> [11,] 1 0.952 5.51
#> [12,] 1 2.007 2.37
#> [13,] 1 1.922 2.80
#> [14,] 1 2.332 2.55
#> [15,] 1 0.422 4.40
#> [16,] 1 0.627 2.20
#> [17,] 1 0.000 2.40
#> [18,] 1 1.657 0.00
#> [19,] 1 1.257 1.00
#> [20,] 1 2.057 0.10
#> [21,] 1 1.267 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
#> 3.262444