{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "fv9OoQsMFk5A" }, "source": [ "# Time series prediction using Support Vector Regressor" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this notebook, we demonstrate how to:\n", "\n", "- prepare 2D time series data for training an SVM regressor model\n", "- implement SVR using RBF kernel\n", "- evaluate the model using plots and MAPE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing modules" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append('../../')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "M687KNlQFp0-" }, "outputs": [], "source": [ "import os\n", "import warnings\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import datetime as dt\n", "import math\n", "\n", "from sklearn.svm import SVR\n", "from sklearn.preprocessing import MinMaxScaler\n", "from common.utils import load_data, mape" ] }, { "cell_type": "markdown", "metadata": { "id": "Cj-kfVdMGjWP" }, "source": [ "## Preparing data" ] }, { "cell_type": "markdown", "metadata": { "id": "8fywSjC6GsRz" }, "source": [ "### Load data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 363 }, "id": "aBDkEB11Fumg", "outputId": "99cf7987-0509-4b73-8cc2-75d7da0d2740" }, "outputs": [ { "data": { "text/html": [ "
\n", " | load | \n", "
---|---|
2012-01-01 00:00:00 | \n", "2698.0 | \n", "
2012-01-01 01:00:00 | \n", "2558.0 | \n", "
2012-01-01 02:00:00 | \n", "2444.0 | \n", "
2012-01-01 03:00:00 | \n", "2402.0 | \n", "
2012-01-01 04:00:00 | \n", "2403.0 | \n", "