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 2
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 5.696215
#>
#> $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 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 0 1 0 0 0 0
#> [9,] 0 0 0 0 0 -1 0 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,] 1 0 0 0 0 0 0 0 0 0
#> [13,] -1 0 0 0 0 0 0 0 0 0
#> [14,] 0 0 0 0 0 0 1 0 0 0
#> [15,] 0 0 0 0 0 0 -1 0 0 0
#> [16,] 0 0 0 0 0 0 0 0 1 0
#> [17,] 0 0 0 0 0 0 0 0 -1 0
#>
#> $cuts
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 0 0 0 0.00 0 0 0 0 0.000
#> [2,] 0 0 4 0 0.00 0 0 0 0 0.000
#> [3,] 0 0 4 0 0.00 0 0 0 0 0.000
#> [4,] 0 0 0 0 0.00 0 0 0 0 1.935
#> [5,] 0 0 0 0 0.00 0 0 0 0 1.935
#> [6,] 0 1 0 0 0.00 0 0 0 0 0.000
#> [7,] 0 1 0 0 0.00 0 0 0 0 0.000
#> [8,] 0 0 0 0 0.00 3 0 0 0 0.000
#> [9,] 0 0 0 0 0.00 3 0 0 0 0.000
#> [10,] 0 0 0 0 2.76 0 0 0 0 0.000
#> [11,] 0 0 0 0 2.76 0 0 0 0 0.000
#> [12,] 0 0 0 0 0.00 0 0 0 0 0.000
#> [13,] 0 0 0 0 0.00 0 0 0 0 0.000
#> [14,] 0 0 0 0 0.00 0 62 0 0 0.000
#> [15,] 0 0 0 0 0.00 0 62 0 0 0.000
#> [16,] 0 0 0 0 0.00 0 0 0 0 0.000
#> [17,] 0 0 0 0 0.00 0 0 0 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] 1.4184783
#> [2,] 3.3086957
#> [3,] -1.0913043
#> [4,] -0.1717391
#> [5,] -0.7815217
#> [6,] -2.1815217
#> [7,] 1.0086957
#> [8,] 1.9086957
#> [9,] -0.1913043
#> [10,] -4.9913043
#> [11,] -0.6913043
#> [12,] -3.0717391
#> [13,] 0.1086957
#> [14,] -0.1913043
#> [15,] -2.0913043
#> [16,] 3.8086957
#> [17,] 2.7282609
#> [18,] 1.4282609
#> [19,] 0.4086957
#> [20,] -0.2815217
#> [21,] -0.3913043
#>
#> $fitted.values
#> [,1]
#> [1,] 19.98152
#> [2,] 15.39130
#> [3,] 15.39130
#> [4,] 24.57174
#> [5,] 19.98152
#> [6,] 19.98152
#> [7,] 15.39130
#> [8,] 15.39130
#> [9,] 15.39130
#> [10,] 15.39130
#> [11,] 15.39130
#> [12,] 24.57174
#> [13,] 15.39130
#> [14,] 15.39130
#> [15,] 15.39130
#> [16,] 15.39130
#> [17,] 24.57174
#> [18,] 24.57174
#> [19,] 15.39130
#> [20,] 19.98152
#> [21,] 15.39130
#>
#> $lenb
#> [1] 17
#>
#> $coefficients
#> [,1]
#> [1,] 24.571739
#> [2,] -2.295109
#>
#> $x
#> [,1] [,2]
#> [1,] 1 2
#> [2,] 1 4
#> [3,] 1 4
#> [4,] 1 0
#> [5,] 1 2
#> [6,] 1 2
#> [7,] 1 4
#> [8,] 1 4
#> [9,] 1 4
#> [10,] 1 4
#> [11,] 1 4
#> [12,] 1 0
#> [13,] 1 4
#> [14,] 1 4
#> [15,] 1 4
#> [16,] 1 4
#> [17,] 1 0
#> [18,] 1 0
#> [19,] 1 4
#> [20,] 1 2
#> [21,] 1 4
#>
#> 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
#> 23.9183