I am trying to use Random Forest to improve the classification to determine if it's profit or not.
ssdata_idx = createDataPartition(ssdata1$Profitable, p = 0.70, list = FALSE)
ssdata_trn = ssdata1[ssdata_idx, ] #Training
ssdata_tst = ssdata1[-ssdata_idx, ] #test
profit.f=randomForest(Profitable~Discount+Sales,subset = ssdata_trn,mtry=3,ntree=1000,importance=TRUE)
profit.f
Error in xj[i] : invalid subscript type 'list'
I don't know why???
importance(profit.f)
*Error in UseMethod("importance") : *
- no applicable method for 'importance' applied to an object of class "rpart"*
varImpPlot(profit.f)
*Error in varImpPlot(profit.f) : *
- This function only works for objects of class `randomForest'*
predict.tree=predict(profit.f,ssdata_tst,type="class")
confusionMatrix(predict.tree,as.factor(ssdata_tst$Profitable))emphasized text