I perform GBM models.
Data sample
a=structure(list(yield = c(1842L, 2147L, 2444L, 3850L, 1866L, 2897L,
1783L, 2434L, 2650L, 2863L), time.diff = c(122, 186, 177, 168,
162, 186, 161, 125, 187, 185), Biomass = c(18400L, 6400L, 8620L,
12800L, 5400L, 10400L, 6000L, 8800L, 9080L, 60000L)), class = "data.frame", row.names = c(NA,
-10L))
my code
indexes = createDataPartition(a$yield, p = .7, list = F)
train = a[indexes, ]
test = a[-indexes, ]
write.csv(test,"test.csv")
ames_train <- train
ames_test <- test
str(ames_train)
# train GBM model
gbm.fit <- gbm(
formula = yield ~ .,
distribution = "gaussian",
data = ames_train,
n.trees = 10000,
interaction.depth = 1,
shrinkage = 0.001,
cv.folds = 5,
n.cores = NULL, # will use all cores by default
verbose = FALSE
)
# print results
print(gbm.fit)
# get MSE and compute RMSE
sqrt(min(gbm.fit$cv.error))
Here indicated MSE and RMSE
How can i calculate r square (Multiple determination coefficient) for this model?
question from:
https://stackoverflow.com/questions/65885376/calculate-r-square-multiple-determination-coefficient-using-gbm-in-r