{ "cells": [ { "cell_type": "markdown", "id": "26f02d07", "metadata": {}, "source": [ "# Stock Price Forecasting\n", "\n", "This notebook contains: data loading, preprocessing, ARIMA (statsmodels), LSTM (Keras), Prophet, rolling-window evaluation, performance table, and how to save and prepare models for upload to Hugging Face Hub.\n", "\n", "**Use the included `sample_stock.csv` if you don't have internet access.**" ] }, { "cell_type": "code", "execution_count": null, "id": "f26d591d", "metadata": {}, "outputs": [], "source": [ "# Install missing packages (uncomment and run if needed)\n", "# !pip install -r requirements.txt\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "377744cd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ready\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from sklearn.metrics import mean_squared_error\n", "from math import sqrt\n", "\n", "# helper metrics\n", "def mape(y_true, y_pred):\n", " y_true, y_pred = np.array(y_true), np.array(y_pred)\n", " return np.mean(np.abs((y_true - y_pred) / np.where(y_true==0, 1e-8, y_true))) * 100\n", "\n", "print('Ready')" ] }, { "cell_type": "code", "execution_count": 2, "id": "f7ca59fd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(523, 2)\n" ] }, { "data": { "text/html": [ "
| \n", " | Date | \n", "Close | \n", "
|---|---|---|
| 0 | \n", "2020-01-01 | \n", "100.546714 | \n", "
| 1 | \n", "2020-01-02 | \n", "100.458450 | \n", "
| 2 | \n", "2020-01-03 | \n", "101.156138 | \n", "
| 3 | \n", "2020-01-06 | \n", "102.729168 | \n", "
| 4 | \n", "2020-01-07 | \n", "102.545015 | \n", "