Reputation: 326
I would like to have a prediction of short term direction of a certain asset. I did an SVM model based on Dane_train data.frame (8058 rows):
SVM1 <- e1071::svm(Direction ~ logReturns_1,
data = Dane_train,
type = "C-classification",
cost = 0.1,
kernel = "linear",
scale = FALSE)
And then I would like to make a prediction of the records from Dane_test data.frame:
pred <- predict(SVM1, data = Dane_test, method = "class")
The first strange thing is that I get factor vector of length 8058 - not 2015 from test data. Then when I do:
table(pred, Dane_test$Direction)
I have an error because of the inappriopriate length of the arguments. What have I done wrong?
Upvotes: 2
Views: 50
Reputation: 37661
The arguments for predict
are a little different. You need newdata=Dane_test
not data=Dane_test
.
Upvotes: 2