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


LearnerRegrMars$new()

Creates a new instance of this R6 class.

Usage


LearnerRegrMars$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', predict_raw = 'FALSE'

# 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
#> 
#> $selected.terms
#> [1] 1 2 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 8.26731
#> 
#> $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    0   0    0    0    0  1    0  0  0
#>  [7,]  0    0   0    0    0    0 -1    0  0  0
#>  [8,]  0    0   0    0    0    1  0    0  0  0
#>  [9,]  0    0   0    0    0   -1  0    0  0  0
#> [10,]  0    1   0    0    0    0  0    0  0  0
#> [11,]  0   -1   0    0    0    0  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,]  1    0   0    0    0    0  0    0  0  0
#> [15,] -1    0   0    0    0    0  0    0  0  0
#> 
#> $cuts
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    0    0    0    0    0    0  0.0    0 0.000
#>  [2,]    0    0    4    0    0    0    0  0.0    0 0.000
#>  [3,]    0    0    4    0    0    0    0  0.0    0 0.000
#>  [4,]    0    0    0    0    0    0    0  0.0    0 1.513
#>  [5,]    0    0    0    0    0    0    0  0.0    0 1.513
#>  [6,]    0    0    0    0    0    0   66  0.0    0 0.000
#>  [7,]    0    0    0    0    0    0   66  0.0    0 0.000
#>  [8,]    0    0    0    0    0    3    0  0.0    0 0.000
#>  [9,]    0    0    0    0    0    3    0  0.0    0 0.000
#> [10,]    0    1    0    0    0    0    0  0.0    0 0.000
#> [11,]    0    1    0    0    0    0    0  0.0    0 0.000
#> [12,]    0    0    0    0    0    0    0 14.5    0 0.000
#> [13,]    0    0    0    0    0    0    0 14.5    0 0.000
#> [14,]    0    0    0    0    0    0    0  0.0    0 0.000
#> [15,]    0    0    0    0    0    0    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -0.8062326
#>  [2,] -3.1747482
#>  [3,]  1.1918151
#>  [4,]  2.4588962
#>  [5,] -1.4501653
#>  [6,] -1.5919505
#>  [7,] -0.9455389
#>  [8,] -0.4038812
#>  [9,]  1.8509467
#> [10,] -0.1279337
#> [11,] -0.9798160
#> [12,]  3.5753345
#> [13,]  6.1029564
#> [14,] -0.5262403
#> [15,] -1.8667861
#> [16,]  0.2912209
#> [17,] -0.4581912
#> [18,]  2.2578157
#> [19,] -1.1662683
#> [20,] -0.8919505
#> [21,] -3.3392828
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 21.80623
#>  [2,] 25.97475
#>  [3,] 20.20818
#>  [4,] 16.24110
#>  [5,] 19.55017
#>  [6,] 15.89195
#>  [7,] 23.74554
#>  [8,] 19.60388
#>  [9,] 14.54905
#> [10,] 15.32793
#> [11,] 11.37982
#> [12,] 11.12467
#> [13,] 26.29704
#> [14,] 16.02624
#> [15,] 15.16679
#> [16,] 27.00878
#> [17,] 26.45819
#> [18,] 28.14218
#> [19,] 16.96627
#> [20,] 15.89195
#> [21,] 24.73928
#> 
#> $lenb
#> [1] 15
#> 
#> $coefficients
#>           [,1]
#> [1,] 28.142184
#> [2,] -1.681389
#> [3,] -2.685794
#> 
#> $x
#>       [,1] [,2]  [,3]
#>  [1,]    1    2 1.107
#>  [2,]    1    0 0.807
#>  [3,]    1    2 1.702
#>  [4,]    1    4 1.927
#>  [5,]    1    2 1.947
#>  [6,]    1    4 2.057
#>  [7,]    1    0 1.637
#>  [8,]    1    2 1.927
#>  [9,]    1    4 2.557
#> [10,]    1    4 2.267
#> [11,]    1    4 3.737
#> [12,]    1    4 3.832
#> [13,]    1    0 0.687
#> [14,]    1    4 2.007
#> [15,]    1    4 2.327
#> [16,]    1    0 0.422
#> [17,]    1    0 0.627
#> [18,]    1    0 0.000
#> [19,]    1    4 1.657
#> [20,]    1    4 2.057
#> [21,]    1    0 1.267
#> 
#> 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.621548