234 points by ml_genius 5 months ago flag hide 24 comments
mlwhiz 5 months ago next
Great work! I'm impressed by the accuracy of your model. How did you handle overfitting with the limited number of data points in stock prices?
financegeek 5 months ago next
I think you might have also used LSTM/GRU to learning long-term dependencies of stock prices. Would you please provide more details about the architecture of your neural network model?
mlwhiz 5 months ago next
I used an LSTM layer with 64 units, followed by two dense layers of 64 and 1 unit respectively with 'relu' and 'linear' activation functions. I also added 2 dropout layers between the LSTM and the dense layers for preventing overfitting. How did you maintain the generalization ability of your model?
financegeek 5 months ago next
That's pretty much the same architecture I would have used. I'm currently working on a stock prediction algorithm and I'm also using LSTM. I would like to compare results once my algo is ready
datajunkie 5 months ago next
Can you share more details on your feature engineering process, mlwhiz? How did you convert the time-series data to supervised data? Which techniques did you use for encoding the categorical variables and scaling the data?
mlwhiz 5 months ago prev next
Stock prices are indeed tough to predict but we can still improve the prediction accuracy using better feature engineering and ML algorithms. I used daily data for feature engineering and it worked well for me. However, it's worth trying different frequencies like weekly or monthly data as well.
datajunkie 5 months ago prev next
I had the same question as mlwhiz. I'm curious to know what preprocessing you did on your data and how you feature engineered your time series data.
mlwhiz 5 months ago next
To handle overfitting, I used regularization and cross-validation. I also experimented with different feature selection methods like backward elimination and forward selection. For preprocessing, I normalized the data and handled missing values using imputation methods.
datajunkie 5 months ago next
Thanks for sharing your methodologies. Would you please also mention what library or frameworks you used for implementing your ML model?
mlwhiz 5 months ago next
I used Tensorflow 2.0 with Keras API. It's one of the most popular frameworks and provides better flexibility and ease of use. For data handling, I used Pandas and Numpy.
financegeek 5 months ago next
Same here, I am using Pandas too! Which data splitting technique did you use to train and test your ML model?
newbie 5 months ago prev next
Thanks for the link, mlwhiz! I've bookmarked it to read more about LSTM.
algogeek 5 months ago prev next
There's also a variant of LSTM called Gated Recurrent Units (GRU) that is more efficient than LSTM for longer sequences. Did you experiment with GRU's in your ML model? If so, would be interesting to compare the results and training times of both.
mlwhiz 5 months ago next
I also experimented with GRU's but didn't get much improvement in prediction accuracy. I also observed longer training times with GRU's. However, your mileage might vary. You should try both and compare the results based on your data.