0

i have time series data like this : enter image description here

and i want to do decision tree classification and prediction , which is my Y(dependent) is open and others is X's(independent), this is my coding :

library(rpart)
library(rpart.plot)

tree <- rpart(close ~., data = DCovid, method = "anova")
tree
rpart.plot(tree)

predict_unseen <-predict(tree, DCovid , type = 'class'):
but the syntax :
predict_unseen <-predict(tree, DCovid , type = 'class')
Error in predict.rpart(tree, DCovid, type = "class") : 
  Invalid prediction for "rpart" object

can anyone help me on prediction

MrFlick
  • 178,638
  • 15
  • 253
  • 268
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please do not post images of data. But even in your image, there is no column named `close` which you use in your model. Is `close` a categorical or numeric variable. It sounds numeric so you can't really predict a "class" for numeric values. Perhaps you want "vector" – MrFlick Mar 10 '22 at 08:01

0 Answers0