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
#> 
#> $selected.terms
#> [1] 1 2 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 8.209044
#> 
#> $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  1    0  0  0
#>  [9,]  0    0   0    0    0    0 -1    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    1  0    0  0  0
#> [13,]  0    0   0    0    0   -1  0    0  0  0
#> [14,]  0    0   0    0    0    0  0    0  1  0
#> [15,]  0    0   0    0    0    0  0    0 -1  0
#> [16,]  0    1   0    0    0    0  0    0  0  0
#> [17,]  0   -1   0    0    0    0  0    0  0  0
#> 
#> $cuts
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#>  [2,]    0    0    0  0.0    0    0    0  0.0    0 1.513
#>  [3,]    0    0    0  0.0    0    0    0  0.0    0 1.513
#>  [4,]    0    0    0  0.0    0    0    0 14.5    0 0.000
#>  [5,]    0    0    0  0.0    0    0    0 14.5    0 0.000
#>  [6,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#>  [7,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0    0    0   52  0.0    0 0.000
#>  [9,]    0    0    0  0.0    0    0   52  0.0    0 0.000
#> [10,]    0    0    0 71.1    0    0    0  0.0    0 0.000
#> [11,]    0    0    0 71.1    0    0    0  0.0    0 0.000
#> [12,]    0    0    0  0.0    0    3    0  0.0    0 0.000
#> [13,]    0    0    0  0.0    0    3    0  0.0    0 0.000
#> [14,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#> [15,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#> [16,]    0    1    0  0.0    0    0    0  0.0    0 0.000
#> [17,]    0    1    0  0.0    0    0    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -1.0587650
#>  [2,]  0.6350331
#>  [3,] -1.8158334
#>  [4,] -0.7854183
#>  [5,]  0.5286116
#>  [6,] -1.2960212
#>  [7,]  1.9685340
#>  [8,] -1.3146103
#>  [9,]  3.4148237
#> [10,]  1.1357289
#> [11,]  4.9172545
#> [12,] -3.9576218
#> [13,] -1.7018264
#> [14,] -2.7922620
#> [15,] -1.0384715
#> [16,]  3.7294604
#> [17,]  1.0262595
#> [18,]  1.6988991
#> [19,] -1.7261784
#> [20,] -0.3093485
#> [21,] -1.2582480
#> 
#> $fitted.values
#>            [,1]
#>  [1,] 22.058765
#>  [2,] 20.764967
#>  [3,] 19.915833
#>  [4,] 23.585418
#>  [5,] 18.671388
#>  [6,] 19.096021
#>  [7,] 14.431466
#>  [8,] 16.514610
#>  [9,]  6.985176
#> [10,] 29.264271
#> [11,] 28.982746
#> [12,] 25.457622
#> [13,] 17.201826
#> [14,] 17.992262
#> [15,] 14.338472
#> [16,] 15.470540
#> [17,] 24.973741
#> [18,] 28.701101
#> [19,] 17.526178
#> [20,] 15.309349
#> [21,] 22.658248
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>            [,1]
#> [1,] 27.0025695
#> [2,] -5.7190049
#> [3,]  0.7077214
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.107 1.96
#>  [2,]    1 1.702 4.94
#>  [3,]    1 1.947 5.72
#>  [4,]    1 1.637 8.40
#>  [5,]    1 1.927 3.80
#>  [6,]    1 1.927 4.40
#>  [7,]    1 2.557 2.90
#>  [8,]    1 2.267 3.50
#>  [9,]    1 3.911 3.32
#> [10,]    1 0.102 4.02
#> [11,]    1 0.322 5.40
#> [12,]    1 0.952 5.51
#> [13,]    1 2.007 2.37
#> [14,]    1 1.922 2.80
#> [15,]    1 2.327 0.91
#> [16,]    1 2.332 2.55
#> [17,]    1 0.627 2.20
#> [18,]    1 0.000 2.40
#> [19,]    1 1.657 0.00
#> [20,]    1 2.057 0.10
#> [21,]    1 1.267 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 
#> 10.70052