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 10 12
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 6.311181
#> 
#> $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    1    0    0  0    0  0  0
#>  [3,]  0    0   0   -1    0    0  0    0  0  0
#>  [4,]  0    1   0    0    0    0  0    0  0  0
#>  [5,]  0   -1   0    0    0    0  0    0  0  0
#>  [6,]  0    0   0    0    0    1  0    0  0  0
#>  [7,]  0    0   0    0    0   -1  0    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   1    0    0    0  0    0  0  0
#> [11,]  0    0  -1    0    0    0  0    0  0  0
#> [12,]  0    0   0    0    0    0  0    0  0  1
#> [13,]  0    0   0    0    0    0  0    0  0 -1
#> [14,]  0    0   0    0    0    0  1    0  0  0
#> [15,]  0    0   0    0    0    0 -1    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
#> 
#> $cuts
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    0    0    0 0.00    0    0    0    0 0.000
#>  [2,]    0    0    0   79 0.00    0    0    0    0 0.000
#>  [3,]    0    0    0   79 0.00    0    0    0    0 0.000
#>  [4,]    0    1    0    0 0.00    0    0    0    0 0.000
#>  [5,]    0    1    0    0 0.00    0    0    0    0 0.000
#>  [6,]    0    0    0    0 0.00    3    0    0    0 0.000
#>  [7,]    0    0    0    0 0.00    3    0    0    0 0.000
#>  [8,]    0    0    0    0 2.76    0    0    0    0 0.000
#>  [9,]    0    0    0    0 2.76    0    0    0    0 0.000
#> [10,]    0    0    4    0 0.00    0    0    0    0 0.000
#> [11,]    0    0    4    0 0.00    0    0    0    0 0.000
#> [12,]    0    0    0    0 0.00    0    0    0    0 1.513
#> [13,]    0    0    0    0 0.00    0    0    0    0 1.513
#> [14,]    0    0    0    0 0.00    0   62    0    0 0.000
#> [15,]    0    0    0    0 0.00    0   62    0    0 0.000
#> [16,]    0    0    0    0 0.00    0    0    0    0 0.000
#> [17,]    0    0    0    0 0.00    0    0    0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,]  0.5059363
#>  [2,] -1.8483833
#>  [3,] -1.6886192
#>  [4,]  1.9336070
#>  [5,]  0.2332856
#>  [6,]  0.1229760
#>  [7,] -1.2770240
#>  [8,]  1.7126664
#>  [9,] -1.3751207
#> [10,] -0.9387227
#> [11,]  3.1631426
#> [12,] -2.7847183
#> [13,] -0.6140209
#> [14,] -1.1272039
#> [15,]  3.9010904
#> [16,]  1.6860233
#> [17,]  3.7276326
#> [18,] -1.1918331
#> [19,] -1.0574073
#> [20,] -0.9886192
#> [21,] -2.0946873
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 20.49406
#>  [2,] 24.64838
#>  [3,] 15.98862
#>  [4,] 22.46639
#>  [5,] 22.56671
#>  [6,] 19.07702
#>  [7,] 19.07702
#>  [8,] 15.58733
#>  [9,] 11.77512
#> [10,] 11.33872
#> [11,] 11.53686
#> [12,] 24.28472
#> [13,] 16.11402
#> [14,] 16.32720
#> [15,] 15.29891
#> [16,] 25.61398
#> [17,] 26.67237
#> [18,] 16.99183
#> [19,] 20.75741
#> [20,] 15.98862
#> [21,] 23.49469
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>           [,1]
#> [1,] 26.672367
#> [2,] -1.381180
#> [3,] -2.508035
#> 
#> $x
#>       [,1] [,2]  [,3]
#>  [1,]    1    2 1.362
#>  [2,]    1    0 0.807
#>  [3,]    1    4 2.057
#>  [4,]    1    0 1.677
#>  [5,]    1    0 1.637
#>  [6,]    1    2 1.927
#>  [7,]    1    2 1.927
#>  [8,]    1    4 2.217
#>  [9,]    1    4 3.737
#> [10,]    1    4 3.911
#> [11,]    1    4 3.832
#> [12,]    1    0 0.952
#> [13,]    1    4 2.007
#> [14,]    1    4 1.922
#> [15,]    1    4 2.332
#> [16,]    1    0 0.422
#> [17,]    1    0 0.000
#> [18,]    1    4 1.657
#> [19,]    1    2 1.257
#> [20,]    1    4 2.057
#> [21,]    1    0 1.267
#> 
#> 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 
#> 13.93663