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 2 4
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 8.199423
#> 
#> $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   1    0    0    0  0    0  0  0
#>  [5,]  0    0  -1    0    0    0  0    0  0  0
#>  [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    0  0    1  0  0
#> [11,]  0    0   0    0    0    0  0   -1  0  0
#> [12,]  0    0   0    1    0    0  0    0  0  0
#> [13,]  0    0   0   -1    0    0  0    0  0  0
#> [14,]  0    0   0    0    0    0  1    0  0  0
#> [15,]  0    0   0    0    0    0 -1    0  0  0
#> [16,]  0    0   0    0    0    0  0    0  1  0
#> [17,]  0    0   0    0    0    0  0    0 -1  0
#> [18,]  0    0   0    0    0    1  0    0  0  0
#> [19,]  0    0   0    0    0   -1  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 0.000
#>  [2,]    0    0    0  0.0    0    0    0  0.0    0 1.513
#>  [3,]    0    0    0  0.0    0    0    0  0.0    0 1.513
#>  [4,]    0    0    4  0.0    0    0    0  0.0    0 0.000
#>  [5,]    0    0    4  0.0    0    0    0  0.0    0 0.000
#>  [6,]    0    1    0  0.0    0    0    0  0.0    0 0.000
#>  [7,]    0    1    0  0.0    0    0    0  0.0    0 0.000
#>  [8,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#>  [9,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#> [10,]    0    0    0  0.0    0    0    0 14.5    0 0.000
#> [11,]    0    0    0  0.0    0    0    0 14.5    0 0.000
#> [12,]    0    0    0 71.1    0    0    0  0.0    0 0.000
#> [13,]    0    0    0 71.1    0    0    0  0.0    0 0.000
#> [14,]    0    0    0  0.0    0    0   52  0.0    0 0.000
#> [15,]    0    0    0  0.0    0    0   52  0.0    0 0.000
#> [16,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#> [17,]    0    0    0  0.0    0    0    0  0.0    0 0.000
#> [18,]    0    0    0  0.0    0    3    0  0.0    0 0.000
#> [19,]    0    0    0  0.0    0    3    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -1.6611102
#>  [2,] -0.6660615
#>  [3,]  1.0606700
#>  [4,]  1.8814712
#>  [5,] -1.2833028
#>  [6,]  1.3202992
#>  [7,] -0.4357869
#>  [8,] -1.6613459
#>  [9,]  1.6130952
#> [10,]  1.3233401
#> [11,]  1.1744103
#> [12,]  5.5328837
#> [13,] -4.4087608
#> [14,] -1.0063566
#> [15,] -1.6380395
#> [16,] -1.9576681
#> [17,]  3.9618426
#> [18,] -0.6769011
#> [19,] -1.1769601
#> [20,]  0.7763909
#> [21,] -2.0721097
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 22.66111
#>  [2,] 21.66606
#>  [3,] 20.33933
#>  [4,] 16.81853
#>  [5,] 19.38330
#>  [6,] 23.07970
#>  [7,] 23.23579
#>  [8,] 19.46135
#>  [9,] 15.68690
#> [10,]  9.07666
#> [11,] 29.22559
#> [12,] 28.36712
#> [13,] 25.90876
#> [14,] 16.50636
#> [15,] 16.83804
#> [16,] 15.25767
#> [17,] 15.23816
#> [18,] 27.97690
#> [19,] 27.17696
#> [20,] 29.62361
#> [21,] 17.87211
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 29.623609
#> [2,] -3.902152
#> [3,] -1.321409
#> 
#> $x
#>       [,1]  [,2] [,3]
#>  [1,]    1 1.107    2
#>  [2,]    1 1.362    2
#>  [3,]    1 1.702    2
#>  [4,]    1 1.927    4
#>  [5,]    1 1.947    2
#>  [6,]    1 1.677    0
#>  [7,]    1 1.637    0
#>  [8,]    1 1.927    2
#>  [9,]    1 2.217    4
#> [10,]    1 3.911    4
#> [11,]    1 0.102    0
#> [12,]    1 0.322    0
#> [13,]    1 0.952    0
#> [14,]    1 2.007    4
#> [15,]    1 1.922    4
#> [16,]    1 2.327    4
#> [17,]    1 2.332    4
#> [18,]    1 0.422    0
#> [19,]    1 0.627    0
#> [20,]    1 0.000    0
#> [21,]    1 1.657    4
#> 
#> 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.947929