Regression with MARS

To do this part of the process, we will build a model with the earth package, review it on the training data, then see how it performs on the test data. We'll run a 10-fold cross-validation with the algorithm:

> set.seed(1492)> earth_fit <-    earth::earth(    x = pca_scores[, 1:5],    y = pca_scores[, 6],    pmethod = 'cv',    nfold = 10,    degree = 1,    minspan = -1 )

Calling the summary of the model object gives us seven total terms with three of the features:

> summary(earth_fit)Call: earth(x=pca_scores[,1:5], y=pca_scores[,6], pmethod="cv", degree=1, nfold=10,            minspan=-1)            coefficients(Intercept)      174.182h(0.1-PC1)       -26.380h(PC1-0.1)        33.806h(0.01-PC2)      -13.181h(PC2-0.01)       13.842h(0.02-PC5)        1.333h(PC5-0.02)        -0.869Selected 7 of 7 terms, ...

Get Mastering Machine Learning with R - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.