{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Wilshire 5000 Predictions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\DORIA\\anaconda3\\envs\\Global\\lib\\site-packages\\numpy\\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:\n",
      "C:\\Users\\DORIA\\anaconda3\\envs\\Global\\lib\\site-packages\\numpy\\.libs\\libopenblas.GK7GX5KEQ4F6UYO3P26ULGBQYHGQO7J4.gfortran-win_amd64.dll\n",
      "C:\\Users\\DORIA\\anaconda3\\envs\\Global\\lib\\site-packages\\numpy\\.libs\\libopenblas.WCDJNK7YVMPZQ2ME2ZZHJJRJ3JIKNDB7.gfortran-win_amd64.dll\n",
      "  warnings.warn(\"loaded more than 1 DLL from .libs:\"\n"
     ]
    }
   ],
   "source": [
    "### Imports\n",
    "import wilshire\n",
    "import nn\n",
    "import tensorflow as tf\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.016058204775629192, 0.0]]\n"
     ]
    }
   ],
   "source": [
    "### ARIMA Predictions\n",
    "\n",
    "x_train,x_test,y_train,y_test,maximum,index = nn.prepare_data()\n",
    "mse = nn.arima_pred(y_train,y_test,orders=[[2,1,1]],n=1)\n",
    "print(mse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense (Dense)                (None, 1)                 2         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 64)                128       \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 64)                4160      \n",
      "_________________________________________________________________\n",
      "dense_3 (Dense)              (None, 1)                 65        \n",
      "=================================================================\n",
      "Total params: 4,355\n",
      "Trainable params: 4,355\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Epoch 1/5\n",
      "6314/6314 [==============================] - 27s 4ms/step - loss: 0.0015\n",
      "Epoch 2/5\n",
      "6314/6314 [==============================] - 24s 4ms/step - loss: 0.0010\n",
      "Epoch 3/5\n",
      "6314/6314 [==============================] - 30s 5ms/step - loss: 9.9259e-04\n",
      "Epoch 4/5\n",
      "6314/6314 [==============================] - 25s 4ms/step - loss: 9.3238e-04\n",
      "Epoch 5/5\n",
      "6314/6314 [==============================] - 26s 4ms/step - loss: 9.0603e-04\n",
      "3/3 [==============================] - 0s 4ms/step - loss: 0.0094\n",
      "198/198 [==============================] - 1s 3ms/step - loss: 6.8375e-04\n",
      "----- ARIMA Test MSE -----\n",
      "ARIMA[2,1,1] : [0.016058204775629192, 0.0]\n",
      "----- DNN Test MSE -----\n",
      "DNN Snake : [0.009417124092578888, 0.0]\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24196 characters]",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Simple training with different activations functions and plotting + printing results\n",
    "#activations = [tf.keras.activations.relu,nn.swish,nn.sinus_cosinus,nn.sinus,nn.snake]\n",
    "activations = [nn.snake]\n",
    "models,errors_train,errors_test = nn.training_testing(n=1,activations=activations,epochs= 5)\n",
    "nn.final_plot(models,errors_test,mse,activations=[\"Snake\"],orders_ARIMA = [\"[2,1,1]\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 35040 characters]",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plot all a with already saved models (the name of the folders should not be changed)\n",
    "## the name of the models' folders should be \"Snake{a_value}a\"\n",
    "nn.plot_all_a(a=[\"1\",\"10\",\"20\",\"30\",\"50\",\"100\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "dc4329e773707249108c96eb096f6a545cc45d5b5791118939d1012dd33cf165"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit ('Global': conda)",
   "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.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
