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 2 6 8
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 8.663097
#> 
#> $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,]  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    0  1    0  0  0
#> [11,]  0    0   0    0    0    0 -1    0  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    0   0    0    0    0  0    1  0  0
#> [17,]  0    0   0    0    0    0  0   -1  0  0
#> [18,]  0    0   0    1    0    0  0    0  0  0
#> [19,]  0    0   0   -1    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    4  0.0 0.00    0    0  0.0    0 0.000
#>  [3,]    0    0    4  0.0 0.00    0    0  0.0    0 0.000
#>  [4,]    0    0    0  0.0 0.00    0    0  0.0    0 1.513
#>  [5,]    0    0    0  0.0 0.00    0    0  0.0    0 1.513
#>  [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    1    0  0.0 0.00    0    0  0.0    0 0.000
#>  [9,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#> [10,]    0    0    0  0.0 0.00    0   52  0.0    0 0.000
#> [11,]    0    0    0  0.0 0.00    0   52  0.0    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    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [17,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [18,]    0    0    0 75.7 0.00    0    0  0.0    0 0.000
#> [19,]    0    0    0 75.7 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -0.8423710
#>  [2,]  0.7783205
#>  [3,]  3.2027168
#>  [4,] -2.5216795
#>  [5,]  1.3905324
#>  [6,]  1.2417398
#>  [7,] -0.3582602
#>  [8,]  1.0600439
#>  [9,]  0.9966246
#> [10,] -2.5094676
#> [11,] -2.5094676
#> [12,]  1.7905324
#> [13,]  2.8454171
#> [14,]  2.1393249
#> [15,] -2.9521679
#> [16,]  0.3905324
#> [17,] -2.2545829
#> [18,] -2.2606751
#> [19,]  2.1393249
#> [20,] -2.2118825
#> [21,]  0.4454446
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 21.84237
#>  [2,] 20.62168
#>  [3,] 15.49728
#>  [4,] 20.62168
#>  [5,] 12.90947
#>  [6,] 23.15826
#>  [7,] 23.15826
#>  [8,] 16.73996
#>  [9,] 14.20338
#> [10,] 12.90947
#> [11,] 12.90947
#> [12,] 12.90947
#> [13,] 29.55458
#> [14,] 28.26068
#> [15,] 24.45217
#> [16,] 12.90947
#> [17,] 29.55458
#> [18,] 28.26068
#> [19,] 28.26068
#> [20,] 18.01188
#> [21,] 19.25456
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 24.452168
#> [2,] -1.915244
#> [3,]  5.102415
#> [4,] -1.293908
#> 
#> $x
#>       [,1] [,2] [,3] [,4]
#>  [1,]    1    2    1    3
#>  [2,]    1    2    0    0
#>  [3,]    1    4    0    1
#>  [4,]    1    2    0    0
#>  [5,]    1    4    0    3
#>  [6,]    1    0    0    1
#>  [7,]    1    0    0    1
#>  [8,]    1    2    0    3
#>  [9,]    1    4    0    2
#> [10,]    1    4    0    3
#> [11,]    1    4    0    3
#> [12,]    1    4    0    3
#> [13,]    1    0    1    0
#> [14,]    1    0    1    1
#> [15,]    1    0    0    0
#> [16,]    1    4    0    3
#> [17,]    1    0    1    0
#> [18,]    1    0    1    1
#> [19,]    1    0    1    1
#> [20,]    1    4    1    3
#> [21,]    1    2    1    5
#> 
#> 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.74835