Videos

Predict The Stock Market With Machine Learning And Python



Dataquest

In this tutorial, we’ll learn how to predict tomorrow’s S&P 500 index price using historical data. We’ll also learn how to avoid common issues that make most stock price models overfit in the real world.

We’ll start by downloading S&P 500 prices using a package called yfinance. Then, we’ll clean up the data with pandas, and get it ready for machine learning.

We’ll train a random forest model and make predictions using backtesting. Then, we’ll improve the model by adding predictors. We’ll end with next steps you can use to improve the model on your own.

You can find an overview of the project and the code here – https://github.com/dataquestio/project-walkthroughs/tree/master/sp_500 .

If you enjoyed this tutorial, check out this link https://bit.ly/3O8MDef for free courses that will help you master data skills.

Chapters

00:00 – Introduction
01:28 – Downloading S&P 500 price data
03:30 – Cleaning and visualizing our stock market data
04:29 – Setting up our target for machine learning
08:19 – Training an initial machine learning model
17:01 – Building a backtesting system
23:05 – Adding additional predictors to our model
28:45 – Improving our model
33:37 – Summary and next steps with the model

———————————
Join 1M+ Dataquest learners today!
Master data skills and change your life.
Sign up for free: https://bit.ly/3O8MDef

Source

Similar Posts

33 thoughts on “Predict The Stock Market With Machine Learning And Python
  1. I thought you couldn't use price as your ML target because there are so many factors contributing to it and you could only predict things like how an indicator would move tomorrow?

  2. Hi, great lesson,
    I have a question.
    I'm still new to data science.
    But why didn't you use the data as a predictor?

    Im asking because say we want to predict what happens in the next day.
    How do i pass it to the model when i didn't train with it

  3. The S&P 500 is still up 10% this year. It's not a get-rich-quick scheme, but it's a proven strategy for wealth accumulation over time, Which happens path i'm considering so as to hedge the losses on my $350k portfolio, but are there any drawbacks to buying such quality stocks?

  4. The last row regenerated by the backtest is 2022-05-17. If the latest existing close is 2022-05-18 (assuming we’re in the morning of 2022-05-19), how is it we can predict the close of 2022-05-19?

    I suppose this has something to do with dropping rows with NaN…

  5. I've tried this on a forex pair, so have like 35 years of data or something like that. I've amped up my precision score to 0.6 but I can't seem to get a accuracy score higher than 0.52. The ultimate goal is 0.75 any advice or pointers here?

  6. Hint: on a recent macbook you can use all its cores by:

    import joblib
    N_CORES = joblib.cpu_count(only_physical_cores=True)

    model = RandomForestClassifier(n_estimators='your value', min_samples_split='your other value', random_state=1, n_jobs=N_CORES)

    The speedup is amazing

  7. Awesome video and awesome explanations – thank you so very much!. Can highly recommend to lookup the various library functions used to even better understand what is going on.
    Precision score '0.5358764759309719'' on initial model and 0.5834394904458599' on the tweaked model on NASDAC…. getting there

  8. Hello, thank you very much for the video, I am new to ML, I would like to know how to use the model? How do I see the prediction for the next day? thanks and greetings

  9. 🎯 Key Takeaways for quick navigation:

    01:10 📉 The tutorial aims to create a machine learning model predicting tomorrow's S&P 500 index price using historical data.
    05:43 🎯 The target for prediction is whether the stock price will go up or down, focusing on directionality rather than absolute price.
    13:48 🔄 The initial model, a random forest classifier, produces predictions with a precision score of 42%, indicating room for improvement.
    21:59 📊 After backtesting, the improved precision score is around 53%, slightly below the natural percentage of days the market went up (53.6%).
    23:12 📈 Additional predictors, such as rolling averages over various periods, are introduced to enhance the model's accuracy in predicting stock market trends.
    24:22 📊 Creating new predictors by calculating rolling averages and ratios based on historical data to enhance algorithm predictions.
    27:16 🚫 Dealing with NaN values resulting from insufficient historical data by explaining the impact on rolling averages and how to handle them.
    28:54 🔄 Adjusting model parameters such as the number of estimators and min sample split to optimize predictions and increase confidence in stock price movements.
    31:39 📈 Selectively choosing informative predictors, like ratios, over absolute values like close/open/high/low, to improve model accuracy.
    33:22 💡 Achieving a 57% success rate in predicting stock price movements, surpassing the baseline, and considering potential model extensions like incorporating global indices, news, and finer temporal resolutions.

    Made with HARPA AI

  10. Congratulations for your explanation and it was very clear. I would like to suggest you to prepare a vide including news about the stock into this model. Thanks

  11. Clear and to the point. I hate super long videos full of things that don't provide much value. This one was great. I like that he walked through general data science/machine learning steps. In particular the data cleansing which many skip over, but it is actually an important step. Also, a pet peeve of mine is audio quality. This video you can hear the presenter clearly and he doesn't sound like his is working from a tin can.

  12. I’m new to coding but have always been an avid market watcher and looking for opportunities. Best video I’ve seen since I started scouring the depths of YouTube for this content last week. Thank you sir!

Comments are closed.

WP2Social Auto Publish Powered By : XYZScripts.com