Open-source ML project

Explore prices.
Test predictions.

A Python machine-learning project that compares Linear Regression and Random Forest on historical stock prices, with expanding walk-forward evaluation instead of random train/test splits.

Built with Python · scikit-learn · yfinance · Streamlit

Model evaluation
Compare before you trust
EDUCATIONAL DEMO
Earlier sessionsLater sessions
MAEAverage absolute error
RMSEPenalizes large errors
R²Relative fit score

Illustrative graphic only — no live market data or forecast is shown on this static page.

Built to learn, measure, and compare.

The goal is not to promise a winning trade. It's to make the modeling process inspectable and compare predictions against a simple baseline.

Historical features

Lagged closes, rolling averages and volatility, plus 5-, 10-, and 20-session momentum features.

Two models + baseline

Compare Linear Regression and Random Forest against a previous-close baseline on later observations.

Time-aware evaluation

Three expanding chronological windows with MAE, RMSE, R², directional accuracy, and an actual-vs-predicted chart.

How the model works

A clear, repeatable pipeline from price history to a one-session forecast.

STEP 01

Get price history

Download adjusted daily closing prices through yfinance.

STEP 02

Build features

Construct lagged and rolling features using prior observations.

STEP 03

Test honestly

Expand the training history and evaluate on later dates, without shuffling.

STEP 04

Compare errors

Measure model errors and compare them with a naive baseline.

Use the predictor online

Deploy the existing Python app to Streamlit Community Cloud. After the one-time deployment, the app runs in the cloud and visitors can use it from a browser without installing Python locally.

1. Deploy to Streamlit

Sign in with GitHub, review the repository settings, and deploy app.py from the main branch.

First deployment requires your own Streamlit/GitHub authorization. Choose a public app if you want others to use it.

2. What the online app does

Users enter a Yahoo Finance ticker, choose 1, 2, 5, or 10 years of daily history, and run an online forecast. The app compares Linear Regression and Random Forest with a previous-close baseline across expanding chronological test windows.

Data timing: The app uses completed daily adjusted closes, omits the current session until its regular close, and caches data for up to one hour. Yahoo Finance availability and delays may vary; this is not a real-time exchange feed. Forecasts are estimates, not buy/sell signals.
Want to run it locally instead?

Install dependencies

python -m venv .venv
python -m pip install -r requirements.txt

Start Streamlit

python -m streamlit run app.py