{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ffcafcca-d896-4122-8de4-d8c410f723d7",
   "metadata": {},
   "source": [
    "# Forecaster Object Globals\n",
    "\n",
    "- In scalecast, it is helpful to know the following terms:\n",
    "\n",
    "[estimators](#estimators)  \n",
    "  \n",
    "  - [estimators that can be tuned](#estimators-that-can-be-tuned)  \n",
    "  - [estimators that cannot be tuned](#estimators-that-cannot-be-tuned)  \n",
    "  - [sklearn estimators](#sklearn-estimators)  \n",
    "  \n",
    "[metrics](#metrics)  \n",
    "[determine_best_by](#determine_best_by)  \n",
    "[normalizer](#normalizer)  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79489a25-ef5f-4b6e-ae56-01550550b547",
   "metadata": {},
   "source": [
    "## estimators\n",
    "- estimators (`_estimators_` in the docs) are the models that actually forecast\n",
    "- they come from popular machine learning libraries like scikit-learn, keras, statsmodels, and others\n",
    "- here is a list of all estimators:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f174071b-08b6-463b-8d6f-73562c75490e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arima\n",
      "combo\n",
      "elasticnet\n",
      "gbt\n",
      "hwes\n",
      "knn\n",
      "lightgbm\n",
      "lstm\n",
      "mlp\n",
      "mlr\n",
      "prophet\n",
      "rf\n",
      "rnn\n",
      "silverkite\n",
      "svr\n",
      "xgboost\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _estimators_\n",
    "print(*_estimators_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74643955-d8d9-4875-9ec3-f865c349c577",
   "metadata": {},
   "source": [
    "### estimators that can be tuned\n",
    "- the following estimators can be tuned by using a process similar to the following:\n",
    "\n",
    "```python\n",
    "from scalecast.Forecaster import Forecaster\n",
    "from scalecast import GridGenerator\n",
    "\n",
    "GridGenerator.get_example_grids()\n",
    "\n",
    "models = ('arima','elasticnet','gbt')\n",
    "f = Forecaster(y=y,current_dates=current_dates)\n",
    "f.set_validation_length(6)\n",
    "\n",
    "for m in models:\n",
    "    f.set_estimator(m)\n",
    "    f.tune()\n",
    "    f.auto_forecast()\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "188e4c7d-5db5-4fdc-a487-2b5a3f6068d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arima\n",
      "elasticnet\n",
      "gbt\n",
      "hwes\n",
      "knn\n",
      "lightgbm\n",
      "mlp\n",
      "mlr\n",
      "prophet\n",
      "rf\n",
      "silverkite\n",
      "svr\n",
      "xgboost\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _can_be_tuned_\n",
    "print(*_can_be_tuned_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "65308432-b018-4e87-8564-e6b23d8af636",
   "metadata": {},
   "source": [
    "### estimators that cannot be tuned"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b7979606-b682-4ed8-8a26-8269f5080b82",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "combo\n",
      "lstm\n",
      "rnn\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _cannot_be_tuned_\n",
    "print(*_cannot_be_tuned_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3be1ad09-63b2-4102-b642-4e85ea0a3bf3",
   "metadata": {},
   "source": [
    "### sklearn estimators\n",
    "- all sklearn estimators accept an Xvars and normalizer argument and these can be tuned as well:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "fddceb66-107d-4357-a998-bd962f4905ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "elasticnet\n",
      "gbt\n",
      "knn\n",
      "lightgbm\n",
      "mlp\n",
      "mlr\n",
      "rf\n",
      "svr\n",
      "xgboost\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _sklearn_estimators_\n",
    "print(*_sklearn_estimators_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c9c4392-71b8-4629-a60a-56d90e4c3688",
   "metadata": {},
   "source": [
    "## metrics\n",
    "- these are all the metrics available to use for model validation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "eb2276f4-9899-45fd-aed6-500973d4567b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "r2\n",
      "rmse\n",
      "mape\n",
      "mae\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _metrics_\n",
    "print(*_metrics_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "33b4e1b2-0cff-49f8-966f-e65a43068ca9",
   "metadata": {},
   "source": [
    "## determine_best_by\n",
    "- these are all the metrics available to use for model comparison and sorting models best-to-worst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7a5773c5-8ad9-4cd7-9eb8-8c79fd6488f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TestSetRMSE\n",
      "TestSetMAPE\n",
      "TestSetMAE\n",
      "TestSetR2\n",
      "InSampleRMSE\n",
      "InSampleMAPE\n",
      "InSampleMAE\n",
      "InSampleR2\n",
      "ValidationMetricValue\n",
      "LevelTestSetRMSE\n",
      "LevelTestSetMAPE\n",
      "LevelTestSetMAE\n",
      "LevelTestSetR2\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _determine_best_by_\n",
    "print(*_determine_best_by_,sep='\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da9dc276-da9f-493b-a4eb-8755c440f93a",
   "metadata": {},
   "source": [
    "## normalizer\n",
    "- these are all the options to scale your data before using an sklearn estimator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "218209fd-a318-4e84-8dbf-1e4d350649ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "minmax\n",
      "normalize\n",
      "scale\n",
      "pt\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "from scalecast.Forecaster import _normalizer_\n",
    "print(*_normalizer_,sep='\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bda547be-85d6-4275-b671-6681833535fd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
