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, 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 2 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 5.994538
#> 
#> $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  0    1  0  0
#>  [5,]  0    0   0    0    0    0  0   -1  0  0
#>  [6,]  1    0   0    0    0    0  0    0  0  0
#>  [7,] -1    0   0    0    0    0  0    0  0  0
#>  [8,]  0    0   0    0    0    0  0    0  1  0
#>  [9,]  0    0   0    0    0    0  0    0 -1  0
#> [10,]  0    0   0    0    1    0  0    0  0  0
#> [11,]  0    0   0    0   -1    0  0    0  0  0
#> [12,]  0    0   1    0    0    0  0    0  0  0
#> [13,]  0    0  -1    0    0    0  0    0  0  0
#> [14,]  0    0   0    0    0    1  0    0  0  0
#> [15,]  0    0   0    0    0   -1  0    0  0  0
#> [16,]  0    1   0    0    0    0  0    0  0  0
#> [17,]  0   -1   0    0    0    0  0    0  0  0
#> [18,]  0    0   0    1    0    0  0    0  0  0
#> [19,]  0    0   0   -1    0    0  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    0 14.5    0 0.000
#>  [5,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#>  [6,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [7,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [9,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [10,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#> [11,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#> [12,]    0    0    4  0.0 0.00    0    0  0.0    0 0.000
#> [13,]    0    0    4  0.0 0.00    0    0  0.0    0 0.000
#> [14,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [15,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [16,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#> [17,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#> [18,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> [19,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -0.6051763
#>  [2,]  0.2273977
#>  [3,]  0.1191012
#>  [4,]  0.9721682
#>  [5,]  0.2341925
#>  [6,] -4.3739155
#>  [7,]  1.5759956
#>  [8,] -0.1683484
#>  [9,] -1.4126810
#> [10,] -2.6149915
#> [11,] -1.5860064
#> [12,]  1.6996979
#> [13,]  0.5740129
#> [14,]  2.5901581
#> [15,] -1.6516386
#> [16,] -0.7151009
#> [17,] -0.9455903
#> [18,]  0.3132826
#> [19,]  1.3865375
#> [20,]  4.7374193
#> [21,] -0.3565147
#> 
#> $fitted.values
#>            [,1]
#>  [1,] 21.605176
#>  [2,] 20.772602
#>  [3,] 21.280899
#>  [4,] 17.727832
#>  [5,] 18.965808
#>  [6,] 25.873915
#>  [7,] 24.424004
#>  [8,] 19.868348
#>  [9,] 22.812681
#> [10,] 20.714992
#> [11,] 15.886006
#> [12,] 14.700302
#> [13,] 16.725987
#> [14,]  7.809842
#> [15,] 17.151639
#> [16,] 14.015101
#> [17,] 16.745590
#> [18,] 14.686717
#> [19,] 29.013462
#> [20,] 29.162581
#> [21,] 27.656515
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>            [,1]
#> [1,] 25.1254451
#> [2,] -5.3889742
#> [3,]  0.9671685
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.005 1.96
#>  [2,]    1 1.260 2.52
#>  [3,]    1 1.600 4.94
#>  [4,]    1 1.825 2.52
#>  [5,]    1 1.825 3.80
#>  [6,]    1 0.850 5.51
#>  [7,]    1 0.525 2.20
#>  [8,]    1 1.155 1.00
#>  [9,]    1 1.165 4.10
#> [10,]    1 1.845 5.72
#> [11,]    1 1.955 1.34
#> [12,]    1 2.455 2.90
#> [13,]    1 2.115 3.10
#> [14,]    1 3.809 3.32
#> [15,]    1 1.905 2.37
#> [16,]    1 2.225 0.91
#> [17,]    1 1.555 0.00
#> [18,]    1 1.955 0.10
#> [19,]    1 0.000 4.02
#> [20,]    1 0.220 5.40
#> [21,]    1 0.320 4.40
#> 
#> 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 
#> 12.12162