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 = lrn("regr.mars")
print(learner)
#> 
#> ── <LearnerRegrMars> (regr.mars): Multivariate Adaptive Regression Splines ─────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3extralearners, and mda
#> • Predict Types: [response]
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties:
#> • Other settings: use_weights = 'error'

# Define a Task
task = tsk("mtcars")

# Create train and test set
ids = 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] 10.85551
#> 
#> $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   1    0    0    0  0    0  0  0
#>  [3,]  0    0  -1    0    0    0  0    0  0  0
#>  [4,]  0    0   0    0    0    0  0    0  0  1
#>  [5,]  0    0   0    0    0    0  0    0  0 -1
#>  [6,]  0    1   0    0    0    0  0    0  0  0
#>  [7,]  0   -1   0    0    0    0  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   0    0    0    1  0    0  0  0
#> [11,]  0    0   0    0    0   -1  0    0  0  0
#> [12,]  0    0   0    1    0    0  0    0  0  0
#> [13,]  0    0   0   -1    0    0  0    0  0  0
#> [14,]  0    0   0    0    0    0  1    0  0  0
#> [15,]  0    0   0    0    0    0 -1    0  0  0
#> [16,]  0    0   0    0    0    0  0    0  1  0
#> [17,]  0    0   0    0    0    0  0    0 -1  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.000
#>  [2,]    0    0    4  0.0 0.00    0    0    0    0 0.000
#>  [3,]    0    0    4  0.0 0.00    0    0    0    0 0.000
#>  [4,]    0    0    0  0.0 0.00    0    0    0    0 1.513
#>  [5,]    0    0    0  0.0 0.00    0    0    0    0 1.513
#>  [6,]    0    1    0  0.0 0.00    0    0    0    0 0.000
#>  [7,]    0    1    0  0.0 0.00    0    0    0    0 0.000
#>  [8,]    0    0    0  0.0 2.76    0    0    0    0 0.000
#>  [9,]    0    0    0  0.0 2.76    0    0    0    0 0.000
#> [10,]    0    0    0  0.0 0.00    3    0    0    0 0.000
#> [11,]    0    0    0  0.0 0.00    3    0    0    0 0.000
#> [12,]    0    0    0 71.1 0.00    0    0    0    0 0.000
#> [13,]    0    0    0 71.1 0.00    0    0    0    0 0.000
#> [14,]    0    0    0  0.0 0.00    0   62    0    0 0.000
#> [15,]    0    0    0  0.0 0.00    0   62    0    0 0.000
#> [16,]    0    0    0  0.0 0.00    0    0    0    0 0.000
#> [17,]    0    0    0  0.0 0.00    0    0    0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -1.5898899
#>  [2,] -0.9231089
#>  [3,] -4.1843503
#>  [4,]  0.3659325
#>  [5,]  1.8642809
#>  [6,] -2.2934347
#>  [7,] -0.3094503
#>  [8,] -2.0140434
#>  [9,] -1.2457312
#> [10,]  1.2225809
#> [11,] -0.7466777
#> [12,]  2.8455276
#> [13,]  5.1018703
#> [14,]  5.6474582
#> [15,] -1.1265329
#> [16,] -1.6487933
#> [17,]  3.4232861
#> [18,] -1.4550193
#> [19,]  1.3054837
#> [20,] -1.7417226
#> [21,] -2.4976658
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 22.58989
#>  [2,] 21.92311
#>  [3,] 26.98435
#>  [4,] 21.03407
#>  [5,] 16.83572
#>  [6,] 20.39343
#>  [7,] 24.70945
#>  [8,] 24.81404
#>  [9,] 20.44573
#> [10,] 16.07742
#> [11,] 15.94668
#> [12,] 11.85447
#> [13,] 27.29813
#> [14,] 28.25254
#> [15,] 16.62653
#> [16,] 16.84879
#> [17,] 15.77671
#> [18,] 27.45502
#> [19,] 29.09452
#> [20,] 17.54172
#> [21,] 22.19767
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>           [,1]
#> [1,] 29.094516
#> [2,] -1.805006
#> [3,] -2.614828
#> 
#> $x
#>       [,1] [,2]  [,3]
#>  [1,]    1    2 1.107
#>  [2,]    1    2 1.362
#>  [3,]    1    0 0.807
#>  [4,]    1    2 1.702
#>  [5,]    1    4 1.927
#>  [6,]    1    2 1.947
#>  [7,]    1    0 1.677
#>  [8,]    1    0 1.637
#>  [9,]    1    2 1.927
#> [10,]    1    4 2.217
#> [11,]    1    4 2.267
#> [12,]    1    4 3.832
#> [13,]    1    0 0.687
#> [14,]    1    0 0.322
#> [15,]    1    4 2.007
#> [16,]    1    4 1.922
#> [17,]    1    4 2.332
#> [18,]    1    0 0.627
#> [19,]    1    0 0.000
#> [20,]    1    4 1.657
#> [21,]    1    2 1.257
#> 
#> 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 
#> 6.763014