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 18
#>
#> $selected.terms
#> [1] 1 6 8
#>
#> $penalty
#> [1] 2
#>
#> $degree
#> [1] 1
#>
#> $nk
#> [1] 21
#>
#> $thresh
#> [1] 0.001
#>
#> $gcv
#> [1] 5.087292
#>
#> $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,] 0 0 0 0 1 0 0 0 0 0
#> [9,] 0 0 0 0 -1 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 0 1 0
#> [13,] 0 0 0 0 0 0 0 0 -1 0
#> [14,] 0 1 0 0 0 0 0 0 0 0
#> [15,] 0 -1 0 0 0 0 0 0 0 0
#> [16,] 1 0 0 0 0 0 0 0 0 0
#> [17,] -1 0 0 0 0 0 0 0 0 0
#> [18,] 0 0 0 0 0 0 0 1 0 0
#> [19,] 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 4 0.0 0.00 0 0 0.0 0 0.000
#> [3,] 0 0 4 0.0 0.00 0 0 0.0 0 0.000
#> [4,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [5,] 0 0 0 0.0 0.00 0 0 0.0 0 1.615
#> [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 2.76 0 0 0.0 0 0.000
#> [9,] 0 0 0 0.0 2.76 0 0 0.0 0 0.000
#> [10,] 0 0 0 75.7 0.00 0 0 0.0 0 0.000
#> [11,] 0 0 0 75.7 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 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [15,] 0 1 0 0.0 0.00 0 0 0.0 0 0.000
#> [16,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [17,] 0 0 0 0.0 0.00 0 0 0.0 0 0.000
#> [18,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#> [19,] 0 0 0 0.0 0.00 0 0 14.5 0 0.000
#>
#> $residuals
#> [,1]
#> [1,] -0.87523875
#> [2,] -0.87523875
#> [3,] 0.42527354
#> [4,] 1.59439419
#> [5,] 1.03808372
#> [6,] 0.12664388
#> [7,] -2.12895964
#> [8,] -3.52895964
#> [9,] 1.11880856
#> [10,] -0.08119144
#> [11,] -3.13550268
#> [12,] 1.19627682
#> [13,] 1.72783420
#> [14,] -0.22037317
#> [15,] -0.01408926
#> [16,] -1.83323611
#> [17,] -1.43113494
#> [18,] 3.63978527
#> [19,] 1.14801060
#> [20,] 0.07246243
#> [21,] 2.03635118
#>
#> $fitted.values
#> [,1]
#> [1,] 21.87524
#> [2,] 21.87524
#> [3,] 17.67473
#> [4,] 12.70561
#> [5,] 23.36192
#> [6,] 22.67336
#> [7,] 21.32896
#> [8,] 21.32896
#> [9,] 15.28119
#> [10,] 15.28119
#> [11,] 13.53550
#> [12,] 13.50372
#> [13,] 28.67217
#> [14,] 21.72037
#> [15,] 15.51409
#> [16,] 17.03324
#> [17,] 14.73113
#> [18,] 15.56021
#> [19,] 24.85199
#> [20,] 15.72754
#> [21,] 17.66365
#>
#> $lenb
#> [1] 19
#>
#> $coefficients
#> [,1]
#> [1,] 20.21947694
#> [2,] -0.04801416
#> [3,] 3.89524832
#>
#> $x
#> [,1] [,2] [,3]
#> [1,] 1 58 1.14
#> [2,] 1 58 1.14
#> [3,] 1 53 0.00
#> [4,] 1 193 0.45
#> [5,] 1 10 0.93
#> [6,] 1 43 1.16
#> [7,] 1 71 1.16
#> [8,] 1 71 1.16
#> [9,] 1 128 0.31
#> [10,] 1 128 0.31
#> [11,] 1 153 0.17
#> [12,] 1 178 0.47
#> [13,] 1 0 2.17
#> [14,] 1 45 0.94
#> [15,] 1 98 0.00
#> [16,] 1 98 0.39
#> [17,] 1 193 0.97
#> [18,] 1 123 0.32
#> [19,] 1 39 1.67
#> [20,] 1 212 1.46
#> [21,] 1 123 0.86
#>
#> 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
#> 25.75349