caret train method not working (something is wrong for all accuracy results) for outcomes with >2 categories

前端 未结 4 557
自闭症患者
自闭症患者 2021-01-22 23:03

Hi I know someone asked similar issues before but no clear answer yet (or I tried their solution without success: Caret error using GBM, but not without caret Caret train method

4条回答
  •  攒了一身酷
    2021-01-22 23:24

    Instead of passing the formula in the train function, pass values for parameters x, y, method etc

    the old way:

    modFit = train(data.df$Label ~ ., 
                     data = data.df, 
                    method = "rpart", 
                    trControl= cntr, 
                    tuneLength = 7)
    

    new way:

    modFit = train(x = data.df.cols, 
                     y = data.df$Label,
                     method = "rpart",
                       trControl = cntrl, 
                       tuneLength = 7)
    

    Note: x = data.df.cols has all columns except the label, data.df.cols = data.df[,2:ncol(data.df)]

提交回复
热议问题