Skip to contents

Multivariate Adaptive Regression Splines. Calls mda::mars() from mda.

Dictionary

This Learner can be instantiated via lrn():

lrn("regr.mars")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”

  • Feature Types: “integer”, “numeric”

  • Required Packages: mlr3, mlr3extralearners, mda

Parameters

IdTypeDefaultLevelsRange
degreeinteger1\([1, \infty)\)
nkinteger-\([1, \infty)\)
penaltynumeric2\([0, \infty)\)
threshnumeric0.001\([0, \infty)\)
prunelogicalTRUETRUE, FALSE-
trace.marslogicalFALSETRUE, FALSE-
forward.steplogicalFALSETRUE, FALSE-

References

Friedman, H J (1991). “Multivariate adaptive regression splines.” The annals of statistics, 19(1), 1–67.

See also

Author

sumny

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrMars

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrMars$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = mlr3::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 = 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  2 10
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 10.84489
#> 
#> $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    0    0    0  0    0  0  1
#>  [3,]  0    0   0    0    0    0  0    0  0 -1
#>  [4,]  0    0   0    0    0    0  1    0  0  0
#>  [5,]  0    0   0    0    0    0 -1    0  0  0
#>  [6,]  0    0   0    0    1    0  0    0  0  0
#>  [7,]  0    0   0    0   -1    0  0    0  0  0
#>  [8,]  0    0   0    1    0    0  0    0  0  0
#>  [9,]  0    0   0   -1    0    0  0    0  0  0
#> [10,]  0    0   0    0    0    0  0    1  0  0
#> [11,]  0    0   0    0    0    0  0   -1  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,]  1    0   0    0    0    0  0    0  0  0
#> [15,] -1    0   0    0    0    0  0    0  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  0.0 0.00    0    0  0.0    0 1.615
#>  [3,]    0    0    0  0.0 0.00    0    0  0.0    0 1.615
#>  [4,]    0    0    0  0.0 0.00    0   52  0.0    0 0.000
#>  [5,]    0    0    0  0.0 0.00    0   52  0.0    0 0.000
#>  [6,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#>  [7,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#>  [8,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#>  [9,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> [10,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [11,]    0    0    0  0.0 0.00    0    0 14.5    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  0.0    0 0.000
#> [15,]    0    0    0  0.0 0.00    0    0  0.0    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,]  0.1192910
#>  [2,] -2.0443308
#>  [3,] -3.1311140
#>  [4,]  2.1633106
#>  [5,] -0.3376371
#>  [6,] -2.2948553
#>  [7,]  0.5212640
#>  [8,] -0.2880390
#>  [9,]  0.1985790
#> [10,]  4.5160534
#> [11,]  2.4800981
#> [12,]  5.6843314
#> [13,] -3.9947516
#> [14,] -2.3511147
#> [15,] -3.4313454
#> [16,]  2.6380673
#> [17,]  0.4611354
#> [18,]  2.1228881
#> [19,] -1.4184770
#> [20,] -0.2396018
#> [21,] -1.3737519
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 20.88071
#>  [2,] 24.84433
#>  [3,] 21.23111
#>  [4,] 22.23669
#>  [5,] 19.53764
#>  [6,] 20.09486
#>  [7,] 15.87874
#>  [8,] 17.58804
#>  [9,] 10.20142
#> [10,] 10.18395
#> [11,] 27.91990
#> [12,] 28.21567
#> [13,] 25.49475
#> [14,] 17.85111
#> [15,] 18.63135
#> [16,] 16.56193
#> [17,] 26.83886
#> [18,] 23.87711
#> [19,] 17.21848
#> [20,] 19.93960
#> [21,] 22.77375
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>           [,1]
#> [1,] 24.186540
#> [2,] -4.481069
#> [3,]  0.928697
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.260 2.52
#>  [2,]    1 0.705 4.11
#>  [3,]    1 1.845 5.72
#>  [4,]    1 1.575 5.50
#>  [5,]    1 1.825 3.80
#>  [6,]    1 1.825 4.40
#>  [7,]    1 2.455 2.90
#>  [8,]    1 2.115 3.10
#>  [9,]    1 3.809 3.32
#> [10,]    1 3.730 2.92
#> [11,]    1 0.000 4.02
#> [12,]    1 0.220 5.40
#> [13,]    1 0.850 5.51
#> [14,]    1 1.905 2.37
#> [15,]    1 1.820 2.80
#> [16,]    1 2.230 2.55
#> [17,]    1 0.320 4.40
#> [18,]    1 0.525 2.20
#> [19,]    1 1.555 0.00
#> [20,]    1 1.155 1.00
#> [21,]    1 1.165 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 
#> 6.932592