Tesla stock price prediction with machine learning using Graphite Note

Hrvoje Smolic
-
16/03/2022

At this point in time, I believe that all readers of this article know who Tesla - the person, inventor - was, and who Tesla - the company - is.

We will focus on the company here. More precisely, on Tesla stock price prediction (TSLA), by using Graphite Note and its time-series no-code machine learning Model.

Tesla's mission is to accelerate the world's transition to sustainable energy. It was founded in 2003 by a group of engineers. They wanted to prove that people didn't need to compromise to drive electric cars. Meaning, electric vehicles can be better, quicker, and more fun to drive than gasoline or diesel-based cars.

Dataset

Our goal is to predict the future stock price, based on historical data. It is easy to pull historical prices from publicly available sources. We pulled data for the past 365 days from Yahoo! finance.

Here is historical data:

tesla stock prices
Image source: Yahoo! finance

We can clearly see that from Mar - Sep 2021 stock prices went up and down between 600 - 800, with a sharp upward trend from Oct 2020.

Let's use this dataset to predict what will the stock price be in the next 365 days. We will start by uploading the dataset into Graphite Note.

In a few mouse clicks, we imported and parsed a CSV file that we previously downloaded from Yahoo! finance. These are the dataset columns:

graphite tesla stock prices csv 1
Dataset columns

On the View Data tab, we can browse through our dataset rows, filter, or search. We have 7 columns and 254 rows. Since we downloaded 365 days, it is clear that some dates are missing from the dataset. Graphite's time series Model is built in a way so that it can handle missing dates pretty well.

graphite tesla stock prices csv 2
Dataset rows

Every uploaded dataset will have a practical Summary tab. It enables, at a glance, to check distributions of numeric columns, number of null values, and different statistical measures. For example, we can spot that for the closing price (CLOSE column), the majority of dates (55 dates) belong to a bin with values from 630 to 697.

We will use the CLOSE column for our prediction. It is the last trading price recorded when the market closed on the day. 

graphite tesla stock prices csv 3
Dataset summary

Time series forecast

Predicting Stock prices is a great use case of machine learning both for financial time series analysis. You can read more about the time series forecast here. In short, time series forecasting is looking at recorded data over time to forecast or predict what might happen in the next time period, under the assumption that future trends will be similar to historical trends.

That being said, don't use the results here as financial advice. This exercise should only be used to demonstrate the power of no-code machine learning to predict time-series datasets. Machine learning models can only "learn" what we feed them - and in this case, that is a historical pattern.

Time series forecast in Graphite

Now we have our dataset ready, we are ready to create a no-code machine learning model in Graphite. We chose the Timeseries Forecast model:

graphite timeseries model selection
Tesla stock price prediction with machine learning using Graphite Note 13

In Graphite, to build a time series model, you need only 2 columns

  • a target column (what are we predicting?)
  • a date column (with dates, weeks, months, ...)

That is all.

In a few mouse clicks, we are going to define a model Scenario.

Our Target column from our dataset:

graphite tesla stock prices model 1
Tesla stock price prediction with machine learning using Graphite Note 14

Our date column from the dataset, with the desired forecast horizon of 365 days:

graphite tesla stock prices model 2
Tesla stock price prediction with machine learning using Graphite Note 15

Run the Model - Tesla Stock Price Prediction

We will leave all other options on default and run this scenario. Graphite will take a sample of 80% of our data and train several machine learning models. Then, it will test those models on the remaining 20% and calculate relevant model scores. The details about the final best model fit, seasonality, trends, results, and predictions will be available on the Results tab.

After a few seconds, we have our results. On the model fit tab Graphite will show historical data in blue, and predicted data in yellow. We have our prediction for the next 365 days immediately ready at our disposal. For example, Graphite predicted a price of 1.35k on 2022-11-05.

Tesla Stock Price Prediction in Graphite
Tesla stock price prediction

Now, we can examine further analysis to try to understand the model and model fit better. There is a clear upward global trend detected in the data, with the details about minimum and maximum data points:

graphite tesla stock prices model results 2
general trend in data

It is always interesting to see what seasonality was detected in historical data. This kind of information can be very valuable in eCommerce and Retail, for example.

In our case, there are 2 seasonal patterns detected - weekly and yearly seasonality. Based on training the model on the last 365 days of TSLA stock prices, it seems that the highest closing prices occur on Saturdays and Sundays, and the lowest is on Fridays.

graphite tesla stock prices model results 3
weekly seasonality

Moreover, it seems that the price is highest in November, regarding yearly seasonality detected. But bear in mind that we had only 1 year of data - so that is not a piece of very reliable information. If we trained the model on 5, 6 years of data - then yearly seasonality will have a much bigger weight.

graphite tesla stock prices model results 4
yearly seasonality

Graphite also tried to detect if USA holidays had any correlation with prices going up or down. It is potentially interesting information that on 11 Nov (Veteran's day) it detected a bigger negative impact on the price.

graphite tesla stock prices model results 5
holiday effects

Conclusion

I hope that this helped you understand how easy it is to train models in a no-code machine learning software like Graphite Note. With just a few mouseclicks, we were able to predict the stock price, and analyze seasonality, trends, and patterns in data.

You can explore all other Models here. Feel free to train your own machine learning model on any dataset with the same ease, or schedule a demo if you need any help or have any questions.

Hope you guys enjoyed it!

Now that you are here...

Graphite Note simplifies the use of Machine Learning in analytics by helping business users to generate no-code machine learning models - without writing a single line of code.

If you liked this blog post, you'll love Graphite!
SIGN UP FREE
No Credit Card Required
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram