I'm trying to use SVM to predict whether the price of a security will go up in the next 7 days using a prediction of the last 14 days of data. So far, I have extracted a dataset with 15 features and around 3000 samples (dates). However, I'm a little confused on how I should split my data for the x training set and y training set (and also for the testing sets for that matter).

Would this kind of split make sense in training?

x training set: (Pseudo code)

[Features from days 1-14 , Features from days 22-35, ......]

y training set: (Pseudo code)

[1 if price(day 21) > price(day 14) else -1 ,1 if price(day 42) > price(day 35) else -1, ....]

However, I feel like I'm losing alot of data due to the nature of the y-training set. Are there any better ways to model this?



1 Answer 1


I am not quite sure I have fully understood how you have prepared the dataset, but anyway this what I think you could do.

  • Take your 3000 samples with your 15 features, and add a new feature with meaning the price went up in the last 7 days. This new feature will be simply your y

  • As for your test and training set, you could just order your samples by date, take the X% older as your training set, and the remaining as test set

You have a kind of toy example in Introduction to Statistical Learning performing a similar kind of setup (section 4.6.1 The Stock Market Data includes a lab in R).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.