How to predict stock prices with Python + Machine Learning!

Manpreet Singh
5 min readFeb 16, 2021

One of my favorite things to do with Machine Learning is forecasting, this pretty much means predicting the future with past data, and what better project to try this on than predicting the stock market! First off, we’re going to be using Google Colab to run this code, luckily for us this code was pretty much already developed, please give all the credit to this website for the code, otherwise let’s get started! Here is the link to access the Google Colab project, you can also copy the code over to your Python IDE if you prefer.

Quick Note: This is a somewhat advanced tutorial, I’m assuming you know you’re way around Python / Object Oriented Programming, a bit of Machine learning, and familiarity with Pandas / Numpy. I have tutorials that should bring you up to speed, but here’s a Basic introduction to Machine Learning that I wrote up, okay now let’s get started!

Importing the packages

As always we’re going to have to import these packages, we’re using numpy, pandas, matplotlib and SciKit-Learn, you can pip install these but since we’re using Google Colab these are already built in. We import these packages by doing this:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics import mean_absolute_error as mae
from…

--

--