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, and mda
#> • Predict Types: [response]
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties:
#> • Other settings: use_weights = 'error'

# 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
#> 
#> $selected.terms
#> [1] 1 2 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 8.072613
#> 
#> $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,]  1    0   0    0    0    0  0    0  0  0
#>  [9,] -1    0   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   0    0    0    0  0    1  0  0
#> [13,]  0    0   0    0    0    0  0   -1  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    1    0    0  0    0  0  0
#> [17,]  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.935
#>  [5,]    0    0    0  0.0 0.00    0    0  0.0    0 1.935
#>  [6,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#>  [7,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#>  [9,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [10,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [11,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [12,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [13,]    0    0    0  0.0 0.00    0    0 14.5    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 78.7 0.00    0    0  0.0    0 0.000
#> [17,]    0    0    0 78.7 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>               [,1]
#>  [1,] -0.933896486
#>  [2,]  2.466853217
#>  [3,] -1.792568279
#>  [4,] -1.617226942
#>  [5,] -1.553940141
#>  [6,] -2.141171331
#>  [7,]  1.697849372
#>  [8,]  1.771597479
#>  [9,] -1.434570528
#> [10,] -1.011723971
#> [11,]  3.096293971
#> [12,]  5.737414863
#> [13,] -0.538734573
#> [14,] -1.045297546
#> [15,] -1.961085732
#> [16,]  3.951065031
#> [17,] -0.006575583
#> [18,] -0.808394295
#> [19,] -1.089287992
#> [20,] -1.869373591
#> [21,] -0.917226942
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 21.93390
#>  [2,] 16.23315
#>  [3,] 19.89257
#>  [4,] 15.91723
#>  [5,] 24.35394
#>  [6,] 19.94117
#>  [7,] 14.70215
#>  [8,] 15.52840
#>  [9,] 11.83457
#> [10,] 11.41172
#> [11,] 11.60371
#> [12,] 26.66259
#> [13,] 16.03873
#> [14,] 16.24530
#> [15,] 15.26109
#> [16,] 15.24893
#> [17,] 27.30658
#> [18,] 26.80839
#> [19,] 16.88929
#> [20,] 21.56937
#> [21,] 15.91723
#> 
#> $lenb
#> [1] 17
#> 
#> $coefficients
#>           [,1]
#> [1,] 27.306576
#> [2,] -1.854012
#> [3,] -2.430153
#> 
#> $x
#>       [,1] [,2]  [,3]
#>  [1,]    1    2 0.685
#>  [2,]    1    4 1.505
#>  [3,]    1    2 1.525
#>  [4,]    1    4 1.635
#>  [5,]    1    0 1.215
#>  [6,]    1    2 1.505
#>  [7,]    1    4 2.135
#>  [8,]    1    4 1.795
#>  [9,]    1    4 3.315
#> [10,]    1    4 3.489
#> [11,]    1    4 3.410
#> [12,]    1    0 0.265
#> [13,]    1    4 1.585
#> [14,]    1    4 1.500
#> [15,]    1    4 1.905
#> [16,]    1    4 1.910
#> [17,]    1    0 0.000
#> [18,]    1    0 0.205
#> [19,]    1    4 1.235
#> [20,]    1    2 0.835
#> [21,]    1    4 1.635
#> 
#> 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 
#> 10.19735