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 10
#> 
#> $penalty
#> [1] 2
#> 
#> $degree
#> [1] 1
#> 
#> $nk
#> [1] 21
#> 
#> $thresh
#> [1] 0.001
#> 
#> $gcv
#> [1] 10.47619
#> 
#> $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    0  0    1  0  0
#> [11,]  0    0   0    0    0    0  0   -1  0  0
#> [12,]  0    0   0    0    0    1  0    0  0  0
#> [13,]  0    0   0    0    0   -1  0    0  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
#> [18,]  0    0   0    0    0    0  0    0  1  0
#> [19,]  0    0   0    0    0    0  0    0 -1  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    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    0    0 14.5    0 0.000
#> [11,]    0    0    0  0.0 0.00    0    0 14.5    0 0.000
#> [12,]    0    0    0  0.0 0.00    3    0  0.0    0 0.000
#> [13,]    0    0    0  0.0 0.00    3    0  0.0    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 71.1 0.00    0    0  0.0    0 0.000
#> [17,]    0    0    0 71.1 0.00    0    0  0.0    0 0.000
#> [18,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> [19,]    0    0    0  0.0 0.00    0    0  0.0    0 0.000
#> 
#> $residuals
#>             [,1]
#>  [1,] -2.4420909
#>  [2,]  0.2544881
#>  [3,]  2.0144579
#>  [4,] -3.9507822
#>  [5,]  2.2865906
#>  [6,] -0.7098876
#>  [7,]  2.2351455
#>  [8,]  0.9247394
#>  [9,] -0.9716224
#> [10,] -4.0970998
#> [11,]  0.8528379
#> [12,]  1.1605000
#> [13,]  1.9143834
#> [14,]  2.1614407
#> [15,] -0.3070556
#> [16,] -1.0114516
#> [17,]  2.4796398
#> [18,] -0.3733192
#> [19,] -4.7173714
#> [20,]  1.3246468
#> [21,]  0.9718106
#> 
#> $fitted.values
#>           [,1]
#>  [1,] 23.44209
#>  [2,] 21.14551
#>  [3,] 16.68554
#>  [4,] 22.05078
#>  [5,] 12.01341
#>  [6,] 23.50989
#>  [7,] 15.56485
#>  [8,] 15.47526
#>  [9,] 16.17162
#> [10,] 14.49710
#> [11,] 13.84716
#> [12,] 31.23950
#> [13,] 28.48562
#> [14,] 31.73856
#> [15,] 21.80706
#> [16,] 16.51145
#> [17,] 16.72036
#> [18,] 26.37332
#> [19,] 20.51737
#> [20,] 18.37535
#> [21,] 14.02819
#> 
#> $lenb
#> [1] 19
#> 
#> $coefficients
#>           [,1]
#> [1,] 15.412133
#> [2,] -1.651311
#> [3,] 10.059170
#> [4,]  1.160603
#> 
#> $x
#>       [,1] [,2] [,3] [,4]
#>  [1,]    1    3    1 2.52
#>  [2,]    1    0    0 4.94
#>  [3,]    1    1    0 2.52
#>  [4,]    1    0    0 5.72
#>  [5,]    1    3    0 1.34
#>  [6,]    1    1    0 8.40
#>  [7,]    1    3    0 4.40
#>  [8,]    1    2    0 2.90
#>  [9,]    1    2    0 3.50
#> [10,]    1    3    0 3.48
#> [11,]    1    3    0 2.92
#> [12,]    1    0    1 4.97
#> [13,]    1    1    1 4.02
#> [14,]    1    0    1 5.40
#> [15,]    1    0    0 5.51
#> [16,]    1    1    0 2.37
#> [17,]    1    1    0 2.55
#> [18,]    1    1    1 2.20
#> [19,]    1    3    1 0.00
#> [20,]    1    5    1 1.00
#> [21,]    1    7    1 0.10
#> 
#> 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 
#> 17.85785