Skip to content

Tesla Random Forest Predictor

A Streamlit research demo that estimates the next closing price with a Random Forest.

How it’s built

How it’s built

Tesla Random Forest Predictor · Streamlit demo predicting Tesla's next-day close with a Random Forest

I trained a 100-tree Random Forest regressor on daily TSLA OHLCV data from 2015 to 2024 pulled with yfinance to predict the next day's close, and built a Streamlit app where users enter today's open, high, low, close and volume. The app recomputes MSE, RMSE, MAE and R² live and falls back to stored metrics when Yahoo Finance rate-limits.

input features (Open, High, Low, Close, Volume)
5
trees in the RandomForestRegressor
100
R² on a random, in-sample split (RMSE 6.68, MAE 3.45)
0.9965
training data range
2015-2024

Technology and what it does here

scikit-learn RandomForestRegressor
Maps today's OHLCV to tomorrow's closing price
yfinance
Downloads TSLA daily prices for training and live evaluation
Streamlit
Input form, prediction and model performance table in app.py
joblib
Saves and loads tesla_rf_model.pkl (18 MB)
pandas / NumPy
Target construction with Close.shift(-1) and metric tables

Implementation details

  • The app caches the model with st.cache_resource and the price download for an hour with st.cache_data(ttl=3600), and flattens yfinance MultiIndex columns.
  • When Yahoo Finance is unavailable the app shows stored benchmark metrics instead of failing.

Technologies

  • Random Forest
  • Time Series
  • Streamlit

Next project · Academic Researcher

MLGuard

Portfolio assistant

Gabriel’s projects, experience, and research