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] 7.771306
#> 
#> $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    1    0    0  0    0  0  0
#>  [7,]  0    0   0   -1    0    0  0    0  0  0
#>  [8,]  0    0   0    0    0    1  0    0  0  0
#>  [9,]  0    0   0    0    0   -1  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,]  0    0   0    0    1    0  0    0  0  0
#> [15,]  0    0   0    0   -1    0  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
#> 
#> $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.513
#>  [3,]    0    0    0  0.0 0.00    0    0  0.0    0 1.513
#>  [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 71.1 0.00    0    0  0.0    0 0.000
#>  [7,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#>  [9,]    0    0    0  0.0 0.00    3    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 2.76    0    0  0.0    0 0.000
#> [15,]    0    0    0  0.0 2.76    0    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
#> 
#> $residuals
#>              [,1]
#>  [1,] -1.60364017
#>  [2,] -2.68899552
#>  [3,] -2.28615201
#>  [4,]  1.36178358
#>  [5,]  0.78407339
#>  [6,] -0.62108883
#>  [7,] -2.02108883
#>  [8,]  1.20942247
#>  [9,]  0.71616888
#> [10,] -1.17894088
#> [11,]  0.94346986
#> [12,]  2.01594302
#> [13,]  0.54828607
#> [14,]  5.41709479
#> [15,] -3.25103178
#> [16,] -3.02273555
#> [17,] -0.49661412
#> [18,]  2.90768884
#> [19,]  2.32298642
#> [20,] -0.05917846
#> [21,] -0.99745118
#> 
#> $fitted.values
#>            [,1]
#>  [1,] 22.603640
#>  [2,] 25.488996
#>  [3,] 20.386152
#>  [4,] 23.038216
#>  [5,] 22.015927
#>  [6,] 19.821089
#>  [7,] 19.821089
#>  [8,] 15.190578
#>  [9,] 16.583831
#> [10,] 16.378941
#> [11,]  9.456530
#> [12,]  8.384057
#> [13,] 29.851714
#> [14,] 28.482905
#> [15,] 24.751032
#> [16,] 18.522736
#> [17,] 13.796614
#> [18,] 16.292311
#> [19,] 28.077014
#> [20,] 15.859178
#> [21,] 20.697451
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>             [,1]
#> [1,] 30.26969001
#> [2,] -4.09780467
#> [3,] -0.03594552
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.362   58
#>  [2,]    1 0.807   41
#>  [3,]    1 1.947   53
#>  [4,]    1 1.677   10
#>  [5,]    1 1.637   43
#>  [6,]    1 1.927   71
#>  [7,]    1 1.927   71
#>  [8,]    1 2.557  128
#>  [9,]    1 2.217  128
#> [10,]    1 2.267  128
#> [11,]    1 3.737  153
#> [12,]    1 3.911  163
#> [13,]    1 0.102    0
#> [14,]    1 0.322   13
#> [15,]    1 0.952   45
#> [16,]    1 2.007   98
#> [17,]    1 2.327  193
#> [18,]    1 2.332  123
#> [19,]    1 0.000   61
#> [20,]    1 1.657  212
#> [21,]    1 1.257  123
#> 
#> 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 
#> 9.835201