Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a dataset "df_train" that contains all my explanatory variables and my target variable (xxx1). Furthermore, I have another dataset that contains the weights to use when fitting Random Forest (xxx2 column). I am trying to implement 3-fold cv but it seems that something is wrong. It says about class probabilities but I am trying to fit a regression random forest. I did not understand what the rest of the errors are about for.

train_control<- trainControl(method="cv", number=3, savePredictions = TRUE)


model2<- caret::train(xxx1~., data=df_train, trControl=train_control, 
                     weights = train$xxx2, method="ranger",
                     ntree = 64)



Something is wrong; all the RMSE metric values are missing:
      RMSE        Rsquared        MAE     
 Min.   : NA   Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA   Max.   : NA  
 NA's   :6     NA's   :6     NA's   :6    
Error: Stopping
In addition: There were 20 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In train.default(x, y, weights = w, ...) :
  cannnot compute class probabilities for regression
2: model fit failed for Fold1: mtry= 2, min.node.size=5, splitrule=variance Error in ranger::ranger(dependent.variable.name = ".outcome", data = x,  : 
  unused argument (ntree = 64)
3: model fit failed for Fold1: mtry=32, min.node.size=5, splitrule=variance Error in ranger::ranger(dependent.variable.name = ".outcome", data = x,  : 
  unused argument (ntree = 64)
4: .....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
919 views
Welcome To Ask or Share your Answers For Others

1 Answer

ntree is not an argument with ranger. If i setup data that looks like yours and run without ntree it works:

df_train = data.frame(matrix(rnorm(1000),ncol=10))
df_train$xxx1 = runif(100)

train = data.frame(xxx2 = runif(100))

model2<- caret::train(xxx1~., data=df_train, trControl=train_control, 
                     weights = train$xxx2, method="ranger")

If you want to set the number of trees, it should be num.trees = :

model2<- caret::train(xxx1~., data=df_train, trControl=train_control, 
                     weights = train$xxx2, method="ranger",num.trees=64)

Random Forest 

100 samples
 10 predictor

No pre-processing
Resampling: Cross-Validated (3 fold) 
Summary of sample sizes: 67, 67, 66 
Resampling results across tuning parameters:

  mtry  splitrule   RMSE       Rsquared    MAE      
   2    variance    0.3003410  0.02482223  0.2519143
   2    extratrees  0.2947161  0.01832931  0.2468836
   6    variance    0.3044287  0.02300354  0.2558410
   6    extratrees  0.3006365  0.01630026  0.2523098
  10    variance    0.3167262  0.01966247  0.2662416
  10    extratrees  0.3023726  0.01428860  0.2530303

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...