When i only used mtry parameter as the tuingrid, it worked but when i added ntree parameter the error becomes Error in train.default(x, y, weights = w, ...): The tuning parameter grid should have columns mtry. The code is as below:
require(RCurl) require(prettyR) library(caret) url <- "https://raw.githubusercontent.com/gastonstat/CreditScoring/master/CleanCreditScoring.csv" cs_data <- getURL(url) cs_data <- read.csv(textConnection(cs_data)) classes <- cs_data[, "Status"] predictors <- cs_data[, -match(c("Status", "Seniority", "Time", "Age", "Expenses", "Income", "Assets", "Debt", "Amount", "Price", "Finrat", "Savings"), colnames(cs_data))] train_set <- createDataPartition(classes, p = 0.8, list = FALSE) set.seed(123) cs_data_train = cs_data[train_set, ] cs_data_test = cs_data[-train_set, ] # Define the tuned parameter grid <- expand.grid(mtry = seq(4,16,4), ntree = c(700, 1000,2000) ) ctrl <- trainControl(method = "cv", number = 10, summaryFunction = twoClassSummary,classProbs = TRUE) rf_fit <- train(Status ~ ., data = cs_data_train, method = "rf", preProcess = c("center", "scale"), tuneGrid = grid, trControl = ctrl, family= "binomial", metric= "ROC" #define which metric to optimize metric='RMSE' ) rf_fit