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 6 8
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 12.01507
#> 
#> $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    1   0    0    0    0  0    0  0  0
#>  [9,]  0   -1   0    0    0    0  0    0  0  0
#> [10,]  0    0   0    0    0    1  0    0  0  0
#> [11,]  0    0   0    0    0   -1  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    0  0    0  1  0
#> [15,]  0    0   0    0    0    0  0    0 -1  0
#> [16,]  0    0   0    0    1    0  0    0  0  0
#> [17,]  0    0   0    0   -1    0  0    0  0  0
#> [18,]  0    0   0    0    0    0  1    0  0  0
#> [19,]  0    0   0    0    0    0 -1    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 0.000
#>  [2,]    0    0    0    0 0.00    0    0  0.0    0 1.513
#>  [3,]    0    0    0    0 0.00    0    0  0.0    0 1.513
#>  [4,]    0    0    0    0 0.00    0    0 14.6    0 0.000
#>  [5,]    0    0    0    0 0.00    0    0 14.6    0 0.000
#>  [6,]    0    0    0    0 0.00    0    0  0.0    0 0.000
#>  [7,]    0    0    0    0 0.00    0    0  0.0    0 0.000
#>  [8,]    0    1    0    0 0.00    0    0  0.0    0 0.000
#>  [9,]    0    1    0    0 0.00    0    0  0.0    0 0.000
#> [10,]    0    0    0    0 0.00    3    0  0.0    0 0.000
#> [11,]    0    0    0    0 0.00    3    0  0.0    0 0.000
#> [12,]    0    0    4    0 0.00    0    0  0.0    0 0.000
#> [13,]    0    0    4    0 0.00    0    0  0.0    0 0.000
#> [14,]    0    0    0    0 0.00    0    0  0.0    0 0.000
#> [15,]    0    0    0    0 0.00    0    0  0.0    0 0.000
#> [16,]    0    0    0    0 2.76    0    0  0.0    0 0.000
#> [17,]    0    0    0    0 2.76    0    0  0.0    0 0.000
#> [18,]    0    0    0    0 0.00    0   52  0.0    0 0.000
#> [19,]    0    0    0    0 0.00    0   52  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -2.4045563
#>  [2,] -0.6722171
#>  [3,]  2.6501320
#>  [4,]  3.0167552
#>  [5,]  0.3116485
#>  [6,]  0.2999199
#>  [7,] -1.6660024
#>  [8,] -0.9296308
#>  [9,]  3.6251169
#> [10,]  3.0857323
#> [11,]  1.1115089
#> [12,]  3.6069649
#> [13,] -2.0812191
#> [14,] -3.6576927
#> [15,] -1.8106230
#> [16,]  0.9138126
#> [17,] -1.8806748
#> [18,]  0.8379904
#> [19,] -0.1133508
#> [20,]  0.5208652
#> [21,] -4.7644798
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 23.40456
#>  [2,] 19.37222
#>  [3,] 20.14987
#>  [4,] 16.18324
#>  [5,] 16.08835
#>  [6,] 17.00008
#>  [7,] 16.86600
#>  [8,] 11.32963
#>  [9,] 11.07488
#> [10,] 29.31427
#> [11,] 29.28849
#> [12,] 30.29304
#> [13,] 23.58122
#> [14,] 19.15769
#> [15,] 15.11062
#> [16,] 18.28619
#> [17,] 27.88067
#> [18,] 29.56201
#> [19,] 19.81335
#> [20,] 14.47913
#> [21,] 26.16448
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 26.134059
#> [2,] -2.681555
#> [3,]  5.022437
#> [4,] -1.594486
#> 
#> $x
#>       [,1]  [,2] [,3] [,4]
#>  [1,]    1 1.107    1    3
#>  [2,]    1 1.927    0    1
#>  [3,]    1 1.637    0    1
#>  [4,]    1 1.927    0    3
#>  [5,]    1 2.557    0    2
#>  [6,]    1 2.217    0    2
#>  [7,]    1 2.267    0    2
#>  [8,]    1 3.737    0    3
#>  [9,]    1 3.832    0    3
#> [10,]    1 0.687    1    0
#> [11,]    1 0.102    1    1
#> [12,]    1 0.322    1    0
#> [13,]    1 0.952    0    0
#> [14,]    1 2.007    0    1
#> [15,]    1 2.327    0    3
#> [16,]    1 2.332    0    1
#> [17,]    1 0.627    1    1
#> [18,]    1 0.000    1    1
#> [19,]    1 1.257    1    5
#> [20,]    1 2.057    1    7
#> [21,]    1 1.267    1    1
#> 
#> 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.35801