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 16 18
#> 
#> $selected.terms
#> [1] 1 2
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 10.16009
#> 
#> $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  1    0  0  0
#>  [5,]  0    0   0    0    0    0 -1    0  0  0
#>  [6,]  0    0   0    0    1    0  0    0  0  0
#>  [7,]  0    0   0    0   -1    0  0    0  0  0
#>  [8,]  0    0   0    1    0    0  0    0  0  0
#>  [9,]  0    0   0   -1    0    0  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   1    0    0    0  0    0  0  0
#> [13,]  0    0  -1    0    0    0  0    0  0  0
#> [14,]  0    0   0    0    0    1  0    0  0  0
#> [15,]  0    0   0    0    0   -1  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,]  1    0   0    0    0    0  0    0  0  0
#> [19,] -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.00    0    0  0.00    0 0.000
#>  [2,]    0    0    0  0.0 0.00    0    0  0.00    0 1.615
#>  [3,]    0    0    0  0.0 0.00    0    0  0.00    0 1.615
#>  [4,]    0    0    0  0.0 0.00    0   52  0.00    0 0.000
#>  [5,]    0    0    0  0.0 0.00    0   52  0.00    0 0.000
#>  [6,]    0    0    0  0.0 2.76    0    0  0.00    0 0.000
#>  [7,]    0    0    0  0.0 2.76    0    0  0.00    0 0.000
#>  [8,]    0    0    0 71.1 0.00    0    0  0.00    0 0.000
#>  [9,]    0    0    0 71.1 0.00    0    0  0.00    0 0.000
#> [10,]    0    1    0  0.0 0.00    0    0  0.00    0 0.000
#> [11,]    0    1    0  0.0 0.00    0    0  0.00    0 0.000
#> [12,]    0    0    4  0.0 0.00    0    0  0.00    0 0.000
#> [13,]    0    0    4  0.0 0.00    0    0  0.00    0 0.000
#> [14,]    0    0    0  0.0 0.00    3    0  0.00    0 0.000
#> [15,]    0    0    0  0.0 0.00    3    0  0.00    0 0.000
#> [16,]    0    0    0  0.0 0.00    0    0 15.41    0 0.000
#> [17,]    0    0    0  0.0 0.00    0    0 15.41    0 0.000
#> [18,]    0    0    0  0.0 0.00    0    0  0.00    0 0.000
#> [19,]    0    0    0  0.0 0.00    0    0  0.00    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -1.4174404
#>  [2,] -2.8924950
#>  [3,]  0.9888994
#>  [4,] -0.3833758
#>  [5,] -0.8653558
#>  [6,] -4.0162459
#>  [7,]  2.0053344
#>  [8,]  0.1166242
#>  [9,]  1.0342537
#> [10,] -1.8770361
#> [11,]  1.9974329
#> [12,]  3.0242068
#> [13,]  5.9993851
#> [14,]  0.5473005
#> [15,]  5.3455203
#> [16,] -3.3368501
#> [17,] -3.1112959
#> [18,] -3.4229761
#> [19,]  2.5065289
#> [20,] -0.6643797
#> [21,] -1.5780353
#> 
#> $fitted.values
#>            [,1]
#>  [1,] 22.417440
#>  [2,] 25.692495
#>  [3,] 20.411101
#>  [4,] 19.083376
#>  [5,] 18.965356
#>  [6,] 18.316246
#>  [7,] 20.794666
#>  [8,] 19.083376
#>  [9,] 15.365746
#> [10,] 17.077036
#> [11,]  8.402567
#> [12,]  7.375793
#> [13,] 26.400615
#> [14,] 29.852700
#> [15,] 28.554480
#> [16,] 24.836850
#> [17,] 18.611296
#> [18,] 16.722976
#> [19,] 16.693471
#> [20,] 27.964380
#> [21,] 22.978035
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 29.852700
#> [2,] -5.900999
#> 
#> $x
#>       [,1]  [,2]
#>  [1,]    1 1.260
#>  [2,]    1 0.705
#>  [3,]    1 1.600
#>  [4,]    1 1.825
#>  [5,]    1 1.845
#>  [6,]    1 1.955
#>  [7,]    1 1.535
#>  [8,]    1 1.825
#>  [9,]    1 2.455
#> [10,]    1 2.165
#> [11,]    1 3.635
#> [12,]    1 3.809
#> [13,]    1 0.585
#> [14,]    1 0.000
#> [15,]    1 0.220
#> [16,]    1 0.850
#> [17,]    1 1.905
#> [18,]    1 2.225
#> [19,]    1 2.230
#> [20,]    1 0.320
#> [21,]    1 1.165
#> 
#> 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 
#> 12.18863