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, mda
#> * Predict Types:  [response]
#> * Feature Types: integer, numeric
#> * Properties: -

# 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 18
#> 
#> $selected.terms
#> [1] 1 6 8
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 5.087292
#> 
#> $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    1    0  0    0  0  0
#>  [9,]  0    0   0    0   -1    0  0    0  0  0
#> [10,]  0    0   0    1    0    0  0    0  0  0
#> [11,]  0    0   0   -1    0    0  0    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    1   0    0    0    0  0    0  0  0
#> [15,]  0   -1   0    0    0    0  0    0  0  0
#> [16,]  1    0   0    0    0    0  0    0  0  0
#> [17,] -1    0   0    0    0    0  0    0  0  0
#> [18,]  0    0   0    0    0    0  0    1  0  0
#> [19,]  0    0   0    0    0    0  0   -1  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.615
#>  [5,]    0    0    0  0.0 0.00    0    0  0.0    0 1.615
#>  [6,]    0    0    0  0.0 0.00    0   52  0.0    0 0.000
#>  [7,]    0    0    0  0.0 0.00    0   52  0.0    0 0.000
#>  [8,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#>  [9,]    0    0    0  0.0 2.76    0    0  0.0    0 0.000
#> [10,]    0    0    0 75.7 0.00    0    0  0.0    0 0.000
#> [11,]    0    0    0 75.7 0.00    0    0  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    1    0  0.0 0.00    0    0  0.0    0 0.000
#> [15,]    0    1    0  0.0 0.00    0    0  0.0    0 0.000
#> [16,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [17,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [18,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [19,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> 
#> $residuals
#>              [,1]
#>  [1,] -0.87523875
#>  [2,] -0.87523875
#>  [3,]  0.42527354
#>  [4,]  1.59439419
#>  [5,]  1.03808372
#>  [6,]  0.12664388
#>  [7,] -2.12895964
#>  [8,] -3.52895964
#>  [9,]  1.11880856
#> [10,] -0.08119144
#> [11,] -3.13550268
#> [12,]  1.19627682
#> [13,]  1.72783420
#> [14,] -0.22037317
#> [15,] -0.01408926
#> [16,] -1.83323611
#> [17,] -1.43113494
#> [18,]  3.63978527
#> [19,]  1.14801060
#> [20,]  0.07246243
#> [21,]  2.03635118
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 21.87524
#>  [2,] 21.87524
#>  [3,] 17.67473
#>  [4,] 12.70561
#>  [5,] 23.36192
#>  [6,] 22.67336
#>  [7,] 21.32896
#>  [8,] 21.32896
#>  [9,] 15.28119
#> [10,] 15.28119
#> [11,] 13.53550
#> [12,] 13.50372
#> [13,] 28.67217
#> [14,] 21.72037
#> [15,] 15.51409
#> [16,] 17.03324
#> [17,] 14.73113
#> [18,] 15.56021
#> [19,] 24.85199
#> [20,] 15.72754
#> [21,] 17.66365
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>             [,1]
#> [1,] 20.21947694
#> [2,] -0.04801416
#> [3,]  3.89524832
#> 
#> $x
#>       [,1] [,2] [,3]
#>  [1,]    1   58 1.14
#>  [2,]    1   58 1.14
#>  [3,]    1   53 0.00
#>  [4,]    1  193 0.45
#>  [5,]    1   10 0.93
#>  [6,]    1   43 1.16
#>  [7,]    1   71 1.16
#>  [8,]    1   71 1.16
#>  [9,]    1  128 0.31
#> [10,]    1  128 0.31
#> [11,]    1  153 0.17
#> [12,]    1  178 0.47
#> [13,]    1    0 2.17
#> [14,]    1   45 0.94
#> [15,]    1   98 0.00
#> [16,]    1   98 0.39
#> [17,]    1  193 0.97
#> [18,]    1  123 0.32
#> [19,]    1   39 1.67
#> [20,]    1  212 1.46
#> [21,]    1  123 0.86
#> 
#> 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 
#> 25.75349