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 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 9.768181
#> 
#> $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    0  0    0  1  0
#> [11,]  0    0   0    0    0    0  0    0 -1  0
#> [12,]  0    0   0    0    0    0  1    0  0  0
#> [13,]  0    0   0    0    0    0 -1    0  0  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    1  0    0  0  0
#> [17,]  0    0   0    0    0   -1  0    0  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    0  0.0 0.00    0    0  0.0    0 1.513
#>  [3,]    0    0    0  0.0 0.00    0    0  0.0    0 1.513
#>  [4,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#>  [5,]    0    0    0  0.0 0.00    0    0 14.5    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    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    0  0.0    0 0.000
#> [11,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [12,]    0    0    0  0.0 0.00    0   65  0.0    0 0.000
#> [13,]    0    0    0  0.0 0.00    0   65  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    3    0  0.0    0 0.000
#> [17,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [18,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> [19,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>              [,1]
#>  [1,] -1.38181311
#>  [2,] -0.33778448
#>  [3,]  0.08031184
#>  [4,] -2.41527118
#>  [5,] -1.74395789
#>  [6,]  0.14325618
#>  [7,] -1.74939229
#>  [8,]  1.79758317
#>  [9,] -1.60530775
#> [10,]  3.43779223
#> [11,]  5.06983086
#> [12,]  4.06421960
#> [13,] -4.71074501
#> [14,] -1.91080727
#> [15,] -1.02486524
#> [16,]  3.55804920
#> [17,]  0.59038139
#> [18,]  1.12850312
#> [19,] -1.72893151
#> [20,] -1.00896739
#> [21,] -0.25208449
#> 
#> $fitted.values
#>            [,1]
#>  [1,] 22.381813
#>  [2,] 21.337784
#>  [3,] 21.319688
#>  [4,] 20.515271
#>  [5,] 24.543958
#>  [6,] 19.056744
#>  [7,] 19.549392
#>  [8,] 14.602417
#>  [9,] 16.805308
#> [10,]  6.962208
#> [11,] 27.330169
#> [12,] 29.835780
#> [13,] 26.210745
#> [14,] 17.410807
#> [15,] 14.324865
#> [16,] 15.641951
#> [17,] 25.409619
#> [18,] 29.271497
#> [19,] 17.528932
#> [20,] 20.708967
#> [21,] 15.252084
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>            [,1]
#> [1,] 27.3009030
#> [2,] -5.8973877
#> [3,]  0.8210808
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.107 1.96
#>  [2,]    1 1.362 2.52
#>  [3,]    1 1.702 4.94
#>  [4,]    1 1.947 5.72
#>  [5,]    1 1.637 8.40
#>  [6,]    1 1.927 3.80
#>  [7,]    1 1.927 4.40
#>  [8,]    1 2.557 2.90
#>  [9,]    1 2.267 3.50
#> [10,]    1 3.911 3.32
#> [11,]    1 0.687 4.97
#> [12,]    1 0.322 5.40
#> [13,]    1 0.952 5.51
#> [14,]    1 2.007 2.37
#> [15,]    1 2.327 0.91
#> [16,]    1 2.332 2.55
#> [17,]    1 0.627 2.20
#> [18,]    1 0.000 2.40
#> [19,]    1 1.657 0.00
#> [20,]    1 1.257 1.00
#> [21,]    1 2.057 0.10
#> 
#> 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 
#> 8.861734