I used
hyper_grid <- expand.grid(
degree = 1:10,
nprune = seq(2, 1000, length.out = 100) %>% floor()
)
head(hyper_grid)
for tuning the MARS model
set.seed(123) # for reproducibility
cv_mars <- train(
x = subset(train, select = -Rm),
y = train[,1],
method = "earth",
metric = "RMSE",
trControl = trainControl(method = "cv", number = 10),
tuneGrid = hyper_grid)
used to train the MARS model with earth library in R and then
# View RMSE R2 MAE #
cv_mars$results %>%
filter(nprune == cv_mars$bestTune$nprune, degree == cv_mars$bestTune$degree)
used to evaluate the performance matrices. HOWEVER, I am looking for
1. Why both models ("cv_mars" and "mars1") produced the same results? What is missing here? Even used another hyper_grid as
`hyper_grid <- expand.grid(
degree = 1:3,
nprune = seq(2, 100, length.out = 10) %>% floor()
)
head(hyper_grid)`
the data is as:
> dput(train)
structure(list(Rm = c(0, 86.7072111207646, 86.2148856067188,
85.0275123081378, 98.9574283231972, 99.9710396756444, 99.8841587025775,
99.7393570807993, 99.9710396756444, 55.4133333333333, 54.5066666666667,
56.8533333333333, 99.68, 99.8133333333333, 99.92, 99.8933333333333,
99.8666666666667, 99.8666666666667, 99.9466666666667, 99.8666666666667,
99.84, 99.5675675675676, 99.2972972972973, 99.4324324324324,
99.5675675675676, 99.5135135135135, 99.4864864864865, 99.5405405405405,
99.8108108108108, 99.7837837837838, 99.8648648648649, 99.8648648648649,
99.8648648648649, 99.7837837837838, 99.8918918918919, 99.8378378378378,
99.2432432432432, 96.3243243243243, 96.2432432432432, 97.1891891891892,
99.8477157360406, 99.7457627118644, 99.9717514124294, 99.8870056497175,
99.7933884297521, 99.2492492492492, 99.6996996996997, 99.7597597597598,
98.2548701298701, 96.25, 96.6764705882353, 96.889705882353, 79.9844236760125,
51.2048192771084, 51.3052208835341, 38.4538152610442, 40.9037558685446,
40.5587668593449, 30.3468208092486, 28.9980732177264, 30.7563025210084,
26.551724137931, 24.7126436781609, 28.5057471264368), IC = c(50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 25, 50, 50, 50, 75, 100, 100, 100,
150, 200, 200, 200, 250, 500, 500, 500, 1000, 1250, 1250, 1250,
1500, 2000, 2000, 2000), Dose = c(0, 2, 2, 2, 5, 10, 10, 10,
15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10), CT = c(120, 120, 120, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 5, 5, 5, 15, 30, 30, 30, 60, 90, 90, 90, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 120, 120), pH = c(4, 4, 4, 4, 4, 4, 4, 4, 4, 2,
2, 2, 4, 6, 6, 6, 8, 10, 10, 10, 12, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), Na = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0.01, 0.01, 0.1, 0.5, 0.5, 0.5,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0)), row.names = c(NA, -64L), class = c("tbl_df", "tbl",
"data.frame"))
> dput(test)
structure(list(Rm = c(0, 0, 99.5945554590211, 99.1891109180423,
99.9420793512887, 99.98, 99.76, 99.7066666666667, 99.8933333333333,
99.9733333333333, 99.68, 99.5733333333334, 99.6216216216216,
99.6216216216216, 99.8378378378378, 99.7567567567567, 99.8918918918919,
99.8648648648649, 99.1351351351351, 99.1621621621622, 99.5431472081218,
99.6954314720812, 99.5867768595041, 99.8140495867768, 97.4512987012987,
98.2467532467532, 78.3878504672897, 79.9065420560748, 41.0211267605634,
41.1971830985916, 19.4117647058824, 30.1680672268908), IC = c(50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 25, 25, 75, 75, 150, 150, 250, 250, 1000, 1000, 1500,
1500), Dose = c(0, 0, 5, 5, 15, 15, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10), CT = c(120, 120, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 15, 15, 60, 60, 120, 120, 120, 120, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120), pH = c(4,
4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), Na = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0)), row.names = c(NA, -32L), class = c("tbl_df",
"tbl", "data.frame"))
hope to get your valuable suggestion and answer best regards Suraj