0

I am trying to make a simple estimate of the error of my Random Forest model in R (using package party). However, I get the error Error in w %*% response@predict_trafo : non-conformable arguments when trying to predict the model on the test data.

Why is that? How can I fix the error?

Here is my code:

dat2_X_test <- dat2_X[1:5000,]
dat2_Y_test <- dat2_Y[1:5000]
dat2_X_train   <- dat2_X[-c(1:5000), ]
dat2_Y_train   <- dat2_Y[-c(1:5000)]

library(party)
forest_2   <- cforest(fmla, data = dat2_X_train, control = cforest_unbiased(mtry = 2))
propFewScat         <- predict(forest_2,  newdata = dat2_X_test, type="prob")
pir
  • 5,513
  • 12
  • 63
  • 101
  • It's not very clear to me what you have done to split your data into testing and training. Your example is also not reproducible because we don't have access to your `dat2_X` and `dat2_Y`. See [How to make a great R reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Marc in the box Jul 16 '14 at 09:34
  • Sorry, I thought the split was a normal way of quickly splitting the data. I simply take the first 5000 observations as test data and use the remaining data (roughly 15000 observations) to train the model. Sadly, it is not possible for me to share the data as it is confidential. – pir Jul 16 '14 at 09:53
  • We don't need to see the data **values**, but it's Euros to blintzes :-) that the dimensions of `w` and `response@predict_trafo` are incompatible with the matrix multiplication you wish to perform. – Carl Witthoft Jul 16 '14 at 11:38
  • Look more closely at how you are subsetting dat2_Y. I think you are missing some commas. – joran Jul 16 '14 at 12:54
  • I had a similar error caused by a simple switch of the x and y datasets `Error in s$v %*% diag(1/s$d) : non-conformable arguments` – andemexoax Mar 30 '19 at 23:58

0 Answers0