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 18
#> 
#> $selected.terms
#> [1]  1  8 10
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 12.14744
#> 
#> $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,]  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  0    1  0  0
#>  [9,]  0    0   0    0    0    0  0   -1  0  0
#> [10,]  0    0   0    0    0    0  0    0  0  1
#> [11,]  0    0   0    0    0    0  0    0  0 -1
#> [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   1    0    0    0  0    0  0  0
#> [15,]  0    0  -1    0    0    0  0    0  0  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  0    0  1  0
#> [19,]  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 0.000
#>  [2,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#>  [3,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#>  [4,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#>  [5,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#>  [6,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [7,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#>  [9,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [10,]    0    0    0  0.0 0.00    0    0  0.0    0 1.835
#> [11,]    0    0    0  0.0 0.00    0    0  0.0    0 1.835
#> [12,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [13,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [14,]    0    0    4  0.0 0.00    0    0  0.0    0 0.000
#> [15,]    0    0    4  0.0 0.00    0    0  0.0    0 0.000
#> [16,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#> [17,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#> [18,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [19,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>               [,1]
#>  [1,]  0.272373610
#>  [2,] -2.138049367
#>  [3,] -0.401102177
#>  [4,]  0.516597405
#>  [5,] -2.028036764
#>  [6,] -3.017608498
#>  [7,]  0.644546379
#>  [8,] -2.507085454
#>  [9,] -0.666075634
#> [10,]  0.289654448
#> [11,]  4.664411458
#> [12,]  5.996013741
#> [13,]  5.389614750
#> [14,] -4.291850102
#> [15,] -2.161721754
#> [16,] -1.349427615
#> [17,]  2.808045693
#> [18,]  0.316164936
#> [19,] -0.887088731
#> [20,]  0.006507146
#> [21,] -1.455883472
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 20.72763
#>  [2,] 24.93805
#>  [3,] 21.80110
#>  [4,] 18.18340
#>  [5,] 16.32804
#>  [6,] 25.81761
#>  [7,] 15.75545
#>  [8,] 17.70709
#>  [9,] 11.06608
#> [10,] 10.11035
#> [11,] 10.03559
#> [12,] 26.40399
#> [13,] 28.51039
#> [14,] 25.79185
#> [15,] 17.66172
#> [16,] 14.64943
#> [17,] 16.39195
#> [18,] 26.98384
#> [19,] 16.68709
#> [20,] 14.99349
#> [21,] 22.85588
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 22.698662
#> [2,]  1.076245
#> [3,] -4.503051
#> 
#> $x
#>       [,1] [,2]  [,3]
#>  [1,]    1 2.52 1.040
#>  [2,]    1 4.11 0.485
#>  [3,]    1 4.94 1.380
#>  [4,]    1 2.52 1.605
#>  [5,]    1 1.34 1.735
#>  [6,]    1 8.40 1.315
#>  [7,]    1 2.90 2.235
#>  [8,]    1 3.50 1.945
#>  [9,]    1 3.48 3.415
#> [10,]    1 3.32 3.589
#> [11,]    1 2.92 3.510
#> [12,]    1 4.97 0.365
#> [13,]    1 5.40 0.000
#> [14,]    1 5.51 0.630
#> [15,]    1 2.37 1.685
#> [16,]    1 0.91 2.005
#> [17,]    1 2.55 2.010
#> [18,]    1 4.40 0.100
#> [19,]    1 0.00 1.335
#> [20,]    1 0.10 1.735
#> [21,]    1 4.10 0.945
#> 
#> 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.842461