Regression Mars Learner
mlr_learners_regr.mars.Rd
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
Examples
# Define the Learner
learner = mlr3::lrn("regr.mars")
print(learner)
#> <LearnerRegrMars:regr.mars>: Multivariate Adaptive Regression Splines
#> * Model: -
#> * Parameters: list()
#> * Packages: mlr3, mlr3extralearners, mda
#> * Predict Types: [response]
#> * Feature Types: integer, numeric
#> * Properties: -
# Define a Task
task = mlr3::tsk("mtcars")
# Create train and test set
ids = mlr3::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 8 12 14
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 12.99489
#>
#> $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 0 0 0 1 0 0 0 0 0
#> [5,] 0 0 0 0 -1 0 0 0 0 0
#> [6,] 0 0 0 0 0 0 1 0 0 0
#> [7,] 0 0 0 0 0 0 -1 0 0 0
#> [8,] 0 0 0 0 0 0 0 0 0 1
#> [9,] 0 0 0 0 0 0 0 0 0 -1
#> [10,] 0 1 0 0 0 0 0 0 0 0
#> [11,] 0 -1 0 0 0 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 0 1 0 0
#> [15,] 0 0 0 0 0 0 0 -1 0 0
#> [16,] 0 0 0 0 0 1 0 0 0 0
#> [17,] 0 0 0 0 0 -1 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 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 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [5,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [6,] 0 0 0 0.0 0.00 0 52 0.0 0 0.000
#> [7,] 0 0 0 0.0 0.00 0 52 0.0 0 0.000
#> [8,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [9,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [10,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [11,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [12,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [13,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [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
#> [16,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#> [17,] 0 0 0 0.0 0.00 3 0 0.0 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] -1.2678284
#> [2,] -3.4228473
#> [3,] 1.2954234
#> [4,] 2.5873230
#> [5,] -2.2523072
#> [6,] 0.2001720
#> [7,] -2.1721102
#> [8,] 1.8374304
#> [9,] -1.1186383
#> [10,] -1.0819512
#> [11,] -0.2973768
#> [12,] 4.2822721
#> [13,] 4.6275302
#> [14,] 1.9915014
#> [15,] 4.3547713
#> [16,] -1.8253867
#> [17,] -0.1491202
#> [18,] -1.3057304
#> [19,] -2.1123583
#> [20,] -0.8664763
#> [21,] -3.3042926
#>
#> $fitted.values
#> [,1]
#> [1,] 22.26783
#> [2,] 26.22285
#> [3,] 20.10458
#> [4,] 16.11268
#> [5,] 20.35231
#> [6,] 14.09983
#> [7,] 24.97211
#> [8,] 14.56257
#> [9,] 16.31864
#> [10,] 11.48195
#> [11,] 10.69738
#> [12,] 10.41773
#> [13,] 27.77247
#> [14,] 28.40850
#> [15,] 29.54523
#> [16,] 23.32539
#> [17,] 15.64912
#> [18,] 16.50573
#> [19,] 17.91236
#> [20,] 20.56648
#> [21,] 24.70429
#>
#> $lenb
#> [1] 17
#>
#> $coefficients
#> [,1]
#> [1,] 18.693761
#> [2,] -3.271959
#> [3,] 4.306494
#> [4,] 1.345334
#>
#> $x
#> [,1] [,2] [,3] [,4]
#> [1,] 1 1.260 1 2.52
#> [2,] 1 0.705 1 4.11
#> [3,] 1 1.600 0 4.94
#> [4,] 1 1.825 0 2.52
#> [5,] 1 1.845 0 5.72
#> [6,] 1 1.955 0 1.34
#> [7,] 1 1.535 0 8.40
#> [8,] 1 2.455 0 2.90
#> [9,] 1 2.165 0 3.50
#> [10,] 1 3.635 0 3.48
#> [11,] 1 3.809 0 3.32
#> [12,] 1 3.730 0 2.92
#> [13,] 1 0.585 1 4.97
#> [14,] 1 0.000 1 4.02
#> [15,] 1 0.220 1 5.40
#> [16,] 1 0.850 0 5.51
#> [17,] 1 1.905 0 2.37
#> [18,] 1 1.820 0 2.80
#> [19,] 1 1.555 1 0.00
#> [20,] 1 1.155 1 1.00
#> [21,] 1 1.165 1 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
#> 5.599368