1291 lines
180 KiB
Plaintext
1291 lines
180 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "b29811c3",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4608</th>\n",
|
||
|
" <td>39.80</td>\n",
|
||
|
" <td>40.22</td>\n",
|
||
|
" <td>39.77</td>\n",
|
||
|
" <td>40.09</td>\n",
|
||
|
" <td>40.09</td>\n",
|
||
|
" <td>27456000</td>\n",
|
||
|
" <td>24-09-13</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4609</th>\n",
|
||
|
" <td>40.00</td>\n",
|
||
|
" <td>40.23</td>\n",
|
||
|
" <td>39.58</td>\n",
|
||
|
" <td>39.89</td>\n",
|
||
|
" <td>39.89</td>\n",
|
||
|
" <td>12162500</td>\n",
|
||
|
" <td>24-09-16</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4610</th>\n",
|
||
|
" <td>39.70</td>\n",
|
||
|
" <td>40.08</td>\n",
|
||
|
" <td>39.31</td>\n",
|
||
|
" <td>39.49</td>\n",
|
||
|
" <td>39.49</td>\n",
|
||
|
" <td>17906900</td>\n",
|
||
|
" <td>24-09-17</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4611</th>\n",
|
||
|
" <td>39.76</td>\n",
|
||
|
" <td>40.99</td>\n",
|
||
|
" <td>39.02</td>\n",
|
||
|
" <td>39.06</td>\n",
|
||
|
" <td>39.06</td>\n",
|
||
|
" <td>41241400</td>\n",
|
||
|
" <td>24-09-18</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4612</th>\n",
|
||
|
" <td>40.10</td>\n",
|
||
|
" <td>40.25</td>\n",
|
||
|
" <td>39.26</td>\n",
|
||
|
" <td>39.72</td>\n",
|
||
|
" <td>39.72</td>\n",
|
||
|
" <td>22277500</td>\n",
|
||
|
" <td>24-09-19</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" Open High Low Close Adj Close Volume Date\n",
|
||
|
"4608 39.80 40.22 39.77 40.09 40.09 27456000 24-09-13\n",
|
||
|
"4609 40.00 40.23 39.58 39.89 39.89 12162500 24-09-16\n",
|
||
|
"4610 39.70 40.08 39.31 39.49 39.49 17906900 24-09-17\n",
|
||
|
"4611 39.76 40.99 39.02 39.06 39.06 41241400 24-09-18\n",
|
||
|
"4612 40.10 40.25 39.26 39.72 39.72 22277500 24-09-19"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import pandas as pd\n",
|
||
|
"import pandas_ta as ta\n",
|
||
|
"import IPython\n",
|
||
|
"\n",
|
||
|
"# Uncomment for Interactive Graphs\n",
|
||
|
"#%matplotlib widget\n",
|
||
|
"\n",
|
||
|
"name = \"GDX\"\n",
|
||
|
"data = pd.read_csv(\"data/\"+name + \".csv\")\n",
|
||
|
"data.tail(5)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "68e700e1",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>index</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th>Diff_Close</th>\n",
|
||
|
" <th>RSI</th>\n",
|
||
|
" <th>EMAF</th>\n",
|
||
|
" <th>EMAM</th>\n",
|
||
|
" <th>EMAS</th>\n",
|
||
|
" <th>BBL_5_2.0</th>\n",
|
||
|
" <th>BBM_5_2.0</th>\n",
|
||
|
" <th>BBU_5_2.0</th>\n",
|
||
|
" <th>BBB_5_2.0</th>\n",
|
||
|
" <th>BBP_5_2.0</th>\n",
|
||
|
" <th>STOCHk_14_3_3</th>\n",
|
||
|
" <th>STOCHd_14_3_3</th>\n",
|
||
|
" <th>Target1</th>\n",
|
||
|
" <th>Target2</th>\n",
|
||
|
" <th>Target3</th>\n",
|
||
|
" <th>Target4</th>\n",
|
||
|
" <th>Target5</th>\n",
|
||
|
" <th>Target6</th>\n",
|
||
|
" <th>Target7</th>\n",
|
||
|
" <th>Target8</th>\n",
|
||
|
" <th>Target9</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4403</th>\n",
|
||
|
" <td>4602</td>\n",
|
||
|
" <td>37.66</td>\n",
|
||
|
" <td>37.83</td>\n",
|
||
|
" <td>37.28</td>\n",
|
||
|
" <td>37.33</td>\n",
|
||
|
" <td>37.33</td>\n",
|
||
|
" <td>16260000</td>\n",
|
||
|
" <td>24-09-05</td>\n",
|
||
|
" <td>-0.33</td>\n",
|
||
|
" <td>47.133189</td>\n",
|
||
|
" <td>37.965111</td>\n",
|
||
|
" <td>37.071605</td>\n",
|
||
|
" <td>33.759355</td>\n",
|
||
|
" <td>36.218919</td>\n",
|
||
|
" <td>37.802</td>\n",
|
||
|
" <td>39.385081</td>\n",
|
||
|
" <td>8.375644</td>\n",
|
||
|
" <td>0.350924</td>\n",
|
||
|
" <td>15.729597</td>\n",
|
||
|
" <td>32.100843</td>\n",
|
||
|
" <td>-0.85</td>\n",
|
||
|
" <td>0.15</td>\n",
|
||
|
" <td>0.46</td>\n",
|
||
|
" <td>0.49</td>\n",
|
||
|
" <td>1.15</td>\n",
|
||
|
" <td>0.29</td>\n",
|
||
|
" <td>-0.11</td>\n",
|
||
|
" <td>-0.21</td>\n",
|
||
|
" <td>-0.70</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4404</th>\n",
|
||
|
" <td>4603</td>\n",
|
||
|
" <td>37.17</td>\n",
|
||
|
" <td>37.43</td>\n",
|
||
|
" <td>36.22</td>\n",
|
||
|
" <td>36.32</td>\n",
|
||
|
" <td>36.32</td>\n",
|
||
|
" <td>19939200</td>\n",
|
||
|
" <td>24-09-06</td>\n",
|
||
|
" <td>-0.85</td>\n",
|
||
|
" <td>41.326931</td>\n",
|
||
|
" <td>37.791941</td>\n",
|
||
|
" <td>37.042130</td>\n",
|
||
|
" <td>33.784834</td>\n",
|
||
|
" <td>35.778392</td>\n",
|
||
|
" <td>37.290</td>\n",
|
||
|
" <td>38.801608</td>\n",
|
||
|
" <td>8.107312</td>\n",
|
||
|
" <td>0.179150</td>\n",
|
||
|
" <td>9.755741</td>\n",
|
||
|
" <td>18.352188</td>\n",
|
||
|
" <td>0.15</td>\n",
|
||
|
" <td>0.46</td>\n",
|
||
|
" <td>0.49</td>\n",
|
||
|
" <td>1.15</td>\n",
|
||
|
" <td>0.29</td>\n",
|
||
|
" <td>-0.11</td>\n",
|
||
|
" <td>-0.21</td>\n",
|
||
|
" <td>-0.70</td>\n",
|
||
|
" <td>-0.38</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" index Open High Low Close Adj Close Volume Date \\\n",
|
||
|
"4403 4602 37.66 37.83 37.28 37.33 37.33 16260000 24-09-05 \n",
|
||
|
"4404 4603 37.17 37.43 36.22 36.32 36.32 19939200 24-09-06 \n",
|
||
|
"\n",
|
||
|
" Diff_Close RSI EMAF EMAM EMAS BBL_5_2.0 \\\n",
|
||
|
"4403 -0.33 47.133189 37.965111 37.071605 33.759355 36.218919 \n",
|
||
|
"4404 -0.85 41.326931 37.791941 37.042130 33.784834 35.778392 \n",
|
||
|
"\n",
|
||
|
" BBM_5_2.0 BBU_5_2.0 BBB_5_2.0 BBP_5_2.0 STOCHk_14_3_3 \\\n",
|
||
|
"4403 37.802 39.385081 8.375644 0.350924 15.729597 \n",
|
||
|
"4404 37.290 38.801608 8.107312 0.179150 9.755741 \n",
|
||
|
"\n",
|
||
|
" STOCHd_14_3_3 Target1 Target2 Target3 Target4 Target5 Target6 \\\n",
|
||
|
"4403 32.100843 -0.85 0.15 0.46 0.49 1.15 0.29 \n",
|
||
|
"4404 18.352188 0.15 0.46 0.49 1.15 0.29 -0.11 \n",
|
||
|
"\n",
|
||
|
" Target7 Target8 Target9 \n",
|
||
|
"4403 -0.11 -0.21 -0.70 \n",
|
||
|
"4404 -0.21 -0.70 -0.38 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Adding indicators\n",
|
||
|
"data['Diff_Close'] = data['Adj Close']-data.Open\n",
|
||
|
"data['RSI']=ta.rsi(data.Close, length=14)\n",
|
||
|
"data['EMAF']=ta.ema(data.Close, length=18)\n",
|
||
|
"data['EMAM']=ta.ema(data.Close, length=50)\n",
|
||
|
"data['EMAS']=ta.ema(data.Close, length=200)\n",
|
||
|
"data.ta.bbands(append=True)\n",
|
||
|
"data.ta.stoch(append=True)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"data['Target1'] = data['Diff_Close'].shift(-1)\n",
|
||
|
"data['Target2'] = data['Diff_Close'].shift(-2)\n",
|
||
|
"data['Target3'] = data['Diff_Close'].shift(-3)\n",
|
||
|
"data['Target4'] = data['Diff_Close'].shift(-4)\n",
|
||
|
"data['Target5'] = data['Diff_Close'].shift(-5)\n",
|
||
|
"data['Target6'] = data['Diff_Close'].shift(-6)\n",
|
||
|
"data['Target7'] = data['Diff_Close'].shift(-7)\n",
|
||
|
"data['Target8'] = data['Diff_Close'].shift(-8)\n",
|
||
|
"data['Target9'] = data['Diff_Close'].shift(-9)\n",
|
||
|
" \n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"data.dropna(inplace=True)\n",
|
||
|
"data.reset_index(inplace = True)\n",
|
||
|
"pd.set_option('display.max_columns', None)\n",
|
||
|
"\n",
|
||
|
"data.tail(2)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "a2b0e972",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>index</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Diff_Close</th>\n",
|
||
|
" <th>RSI</th>\n",
|
||
|
" <th>EMAF</th>\n",
|
||
|
" <th>EMAM</th>\n",
|
||
|
" <th>EMAS</th>\n",
|
||
|
" <th>BBL_5_2.0</th>\n",
|
||
|
" <th>BBM_5_2.0</th>\n",
|
||
|
" <th>BBU_5_2.0</th>\n",
|
||
|
" <th>BBB_5_2.0</th>\n",
|
||
|
" <th>BBP_5_2.0</th>\n",
|
||
|
" <th>STOCHk_14_3_3</th>\n",
|
||
|
" <th>STOCHd_14_3_3</th>\n",
|
||
|
" <th>Target1</th>\n",
|
||
|
" <th>Target2</th>\n",
|
||
|
" <th>Target3</th>\n",
|
||
|
" <th>Target4</th>\n",
|
||
|
" <th>Target5</th>\n",
|
||
|
" <th>Target6</th>\n",
|
||
|
" <th>Target7</th>\n",
|
||
|
" <th>Target8</th>\n",
|
||
|
" <th>Target9</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>199</td>\n",
|
||
|
" <td>38.70</td>\n",
|
||
|
" <td>38.70</td>\n",
|
||
|
" <td>37.97</td>\n",
|
||
|
" <td>32.99</td>\n",
|
||
|
" <td>-5.71</td>\n",
|
||
|
" <td>42.823849</td>\n",
|
||
|
" <td>39.130266</td>\n",
|
||
|
" <td>39.242898</td>\n",
|
||
|
" <td>38.151400</td>\n",
|
||
|
" <td>36.894752</td>\n",
|
||
|
" <td>37.894</td>\n",
|
||
|
" <td>38.893248</td>\n",
|
||
|
" <td>5.273910</td>\n",
|
||
|
" <td>0.568051</td>\n",
|
||
|
" <td>26.968411</td>\n",
|
||
|
" <td>24.878202</td>\n",
|
||
|
" <td>-4.50</td>\n",
|
||
|
" <td>-6.22</td>\n",
|
||
|
" <td>-4.61</td>\n",
|
||
|
" <td>-4.51</td>\n",
|
||
|
" <td>-5.38</td>\n",
|
||
|
" <td>-4.97</td>\n",
|
||
|
" <td>-5.43</td>\n",
|
||
|
" <td>-4.69</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>200</td>\n",
|
||
|
" <td>38.02</td>\n",
|
||
|
" <td>38.73</td>\n",
|
||
|
" <td>37.93</td>\n",
|
||
|
" <td>33.52</td>\n",
|
||
|
" <td>-4.50</td>\n",
|
||
|
" <td>46.633750</td>\n",
|
||
|
" <td>39.079712</td>\n",
|
||
|
" <td>39.219647</td>\n",
|
||
|
" <td>38.156361</td>\n",
|
||
|
" <td>37.773181</td>\n",
|
||
|
" <td>38.240</td>\n",
|
||
|
" <td>38.706819</td>\n",
|
||
|
" <td>2.441522</td>\n",
|
||
|
" <td>0.939142</td>\n",
|
||
|
" <td>29.608675</td>\n",
|
||
|
" <td>27.927078</td>\n",
|
||
|
" <td>-6.22</td>\n",
|
||
|
" <td>-4.61</td>\n",
|
||
|
" <td>-4.51</td>\n",
|
||
|
" <td>-5.38</td>\n",
|
||
|
" <td>-4.97</td>\n",
|
||
|
" <td>-5.43</td>\n",
|
||
|
" <td>-4.69</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" <td>-5.36</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>201</td>\n",
|
||
|
" <td>38.44</td>\n",
|
||
|
" <td>38.75</td>\n",
|
||
|
" <td>37.06</td>\n",
|
||
|
" <td>32.22</td>\n",
|
||
|
" <td>-6.22</td>\n",
|
||
|
" <td>39.735192</td>\n",
|
||
|
" <td>38.876584</td>\n",
|
||
|
" <td>39.138484</td>\n",
|
||
|
" <td>38.146348</td>\n",
|
||
|
" <td>37.049243</td>\n",
|
||
|
" <td>38.054</td>\n",
|
||
|
" <td>39.058757</td>\n",
|
||
|
" <td>5.280689</td>\n",
|
||
|
" <td>0.050140</td>\n",
|
||
|
" <td>23.950967</td>\n",
|
||
|
" <td>26.842684</td>\n",
|
||
|
" <td>-4.61</td>\n",
|
||
|
" <td>-4.51</td>\n",
|
||
|
" <td>-5.38</td>\n",
|
||
|
" <td>-4.97</td>\n",
|
||
|
" <td>-5.43</td>\n",
|
||
|
" <td>-4.69</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" <td>-5.36</td>\n",
|
||
|
" <td>-5.46</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>202</td>\n",
|
||
|
" <td>37.01</td>\n",
|
||
|
" <td>37.48</td>\n",
|
||
|
" <td>36.46</td>\n",
|
||
|
" <td>32.40</td>\n",
|
||
|
" <td>-4.61</td>\n",
|
||
|
" <td>41.049977</td>\n",
|
||
|
" <td>38.716944</td>\n",
|
||
|
" <td>39.068740</td>\n",
|
||
|
" <td>38.138523</td>\n",
|
||
|
" <td>36.764084</td>\n",
|
||
|
" <td>37.908</td>\n",
|
||
|
" <td>39.051916</td>\n",
|
||
|
" <td>6.035223</td>\n",
|
||
|
" <td>0.260472</td>\n",
|
||
|
" <td>20.792079</td>\n",
|
||
|
" <td>24.783907</td>\n",
|
||
|
" <td>-4.51</td>\n",
|
||
|
" <td>-5.38</td>\n",
|
||
|
" <td>-4.97</td>\n",
|
||
|
" <td>-5.43</td>\n",
|
||
|
" <td>-4.69</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" <td>-5.36</td>\n",
|
||
|
" <td>-5.46</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>203</td>\n",
|
||
|
" <td>37.68</td>\n",
|
||
|
" <td>38.44</td>\n",
|
||
|
" <td>37.68</td>\n",
|
||
|
" <td>33.17</td>\n",
|
||
|
" <td>-4.51</td>\n",
|
||
|
" <td>46.333706</td>\n",
|
||
|
" <td>38.666739</td>\n",
|
||
|
" <td>39.036240</td>\n",
|
||
|
" <td>38.139533</td>\n",
|
||
|
" <td>36.773123</td>\n",
|
||
|
" <td>37.886</td>\n",
|
||
|
" <td>38.998877</td>\n",
|
||
|
" <td>5.874874</td>\n",
|
||
|
" <td>0.659047</td>\n",
|
||
|
" <td>20.107004</td>\n",
|
||
|
" <td>21.616683</td>\n",
|
||
|
" <td>-5.38</td>\n",
|
||
|
" <td>-4.97</td>\n",
|
||
|
" <td>-5.43</td>\n",
|
||
|
" <td>-4.69</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" <td>-5.36</td>\n",
|
||
|
" <td>-5.46</td>\n",
|
||
|
" <td>-5.66</td>\n",
|
||
|
" <td>-5.34</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" index Open High Low Adj Close Diff_Close RSI EMAF \\\n",
|
||
|
"0 199 38.70 38.70 37.97 32.99 -5.71 42.823849 39.130266 \n",
|
||
|
"1 200 38.02 38.73 37.93 33.52 -4.50 46.633750 39.079712 \n",
|
||
|
"2 201 38.44 38.75 37.06 32.22 -6.22 39.735192 38.876584 \n",
|
||
|
"3 202 37.01 37.48 36.46 32.40 -4.61 41.049977 38.716944 \n",
|
||
|
"4 203 37.68 38.44 37.68 33.17 -4.51 46.333706 38.666739 \n",
|
||
|
"\n",
|
||
|
" EMAM EMAS BBL_5_2.0 BBM_5_2.0 BBU_5_2.0 BBB_5_2.0 \\\n",
|
||
|
"0 39.242898 38.151400 36.894752 37.894 38.893248 5.273910 \n",
|
||
|
"1 39.219647 38.156361 37.773181 38.240 38.706819 2.441522 \n",
|
||
|
"2 39.138484 38.146348 37.049243 38.054 39.058757 5.280689 \n",
|
||
|
"3 39.068740 38.138523 36.764084 37.908 39.051916 6.035223 \n",
|
||
|
"4 39.036240 38.139533 36.773123 37.886 38.998877 5.874874 \n",
|
||
|
"\n",
|
||
|
" BBP_5_2.0 STOCHk_14_3_3 STOCHd_14_3_3 Target1 Target2 Target3 \\\n",
|
||
|
"0 0.568051 26.968411 24.878202 -4.50 -6.22 -4.61 \n",
|
||
|
"1 0.939142 29.608675 27.927078 -6.22 -4.61 -4.51 \n",
|
||
|
"2 0.050140 23.950967 26.842684 -4.61 -4.51 -5.38 \n",
|
||
|
"3 0.260472 20.792079 24.783907 -4.51 -5.38 -4.97 \n",
|
||
|
"4 0.659047 20.107004 21.616683 -5.38 -4.97 -5.43 \n",
|
||
|
"\n",
|
||
|
" Target4 Target5 Target6 Target7 Target8 Target9 \n",
|
||
|
"0 -4.51 -5.38 -4.97 -5.43 -4.69 -5.66 \n",
|
||
|
"1 -5.38 -4.97 -5.43 -4.69 -5.66 -5.36 \n",
|
||
|
"2 -4.97 -5.43 -4.69 -5.66 -5.36 -5.46 \n",
|
||
|
"3 -5.43 -4.69 -5.66 -5.36 -5.46 -5.66 \n",
|
||
|
"4 -4.69 -5.66 -5.36 -5.46 -5.66 -5.34 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data.drop(['Volume', 'Close', 'Date'], axis=1, inplace=True)\n",
|
||
|
"data_set = data\n",
|
||
|
"\n",
|
||
|
"data_set.head()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "b9d38e4c",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>index</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Diff_Close</th>\n",
|
||
|
" <th>RSI</th>\n",
|
||
|
" <th>EMAF</th>\n",
|
||
|
" <th>EMAM</th>\n",
|
||
|
" <th>EMAS</th>\n",
|
||
|
" <th>BBL_5_2.0</th>\n",
|
||
|
" <th>BBM_5_2.0</th>\n",
|
||
|
" <th>BBU_5_2.0</th>\n",
|
||
|
" <th>BBB_5_2.0</th>\n",
|
||
|
" <th>BBP_5_2.0</th>\n",
|
||
|
" <th>STOCHk_14_3_3</th>\n",
|
||
|
" <th>STOCHd_14_3_3</th>\n",
|
||
|
" <th>Target1</th>\n",
|
||
|
" <th>Target2</th>\n",
|
||
|
" <th>Target3</th>\n",
|
||
|
" <th>Target4</th>\n",
|
||
|
" <th>Target5</th>\n",
|
||
|
" <th>Target6</th>\n",
|
||
|
" <th>Target7</th>\n",
|
||
|
" <th>Target8</th>\n",
|
||
|
" <th>Target9</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4400</th>\n",
|
||
|
" <td>4599</td>\n",
|
||
|
" <td>-0.032629</td>\n",
|
||
|
" <td>-0.035886</td>\n",
|
||
|
" <td>-0.032090</td>\n",
|
||
|
" <td>0.134366</td>\n",
|
||
|
" <td>0.357534</td>\n",
|
||
|
" <td>0.135110</td>\n",
|
||
|
" <td>-0.011064</td>\n",
|
||
|
" <td>-0.023456</td>\n",
|
||
|
" <td>-0.152467</td>\n",
|
||
|
" <td>-0.007310</td>\n",
|
||
|
" <td>-0.014559</td>\n",
|
||
|
" <td>-0.050959</td>\n",
|
||
|
" <td>-0.884847</td>\n",
|
||
|
" <td>-0.358144</td>\n",
|
||
|
" <td>0.330323</td>\n",
|
||
|
" <td>0.488259</td>\n",
|
||
|
" <td>0.279452</td>\n",
|
||
|
" <td>0.383562</td>\n",
|
||
|
" <td>0.335616</td>\n",
|
||
|
" <td>0.264384</td>\n",
|
||
|
" <td>0.401370</td>\n",
|
||
|
" <td>0.443836</td>\n",
|
||
|
" <td>0.447945</td>\n",
|
||
|
" <td>0.538356</td>\n",
|
||
|
" <td>0.420548</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4401</th>\n",
|
||
|
" <td>4600</td>\n",
|
||
|
" <td>-0.061550</td>\n",
|
||
|
" <td>-0.068073</td>\n",
|
||
|
" <td>-0.085821</td>\n",
|
||
|
" <td>0.077857</td>\n",
|
||
|
" <td>0.279452</td>\n",
|
||
|
" <td>-0.115170</td>\n",
|
||
|
" <td>-0.015294</td>\n",
|
||
|
" <td>-0.023108</td>\n",
|
||
|
" <td>-0.150777</td>\n",
|
||
|
" <td>-0.047258</td>\n",
|
||
|
" <td>-0.029421</td>\n",
|
||
|
" <td>-0.041646</td>\n",
|
||
|
" <td>-0.762153</td>\n",
|
||
|
" <td>-0.905362</td>\n",
|
||
|
" <td>0.020945</td>\n",
|
||
|
" <td>0.291154</td>\n",
|
||
|
" <td>0.383562</td>\n",
|
||
|
" <td>0.335616</td>\n",
|
||
|
" <td>0.264384</td>\n",
|
||
|
" <td>0.401370</td>\n",
|
||
|
" <td>0.443836</td>\n",
|
||
|
" <td>0.447945</td>\n",
|
||
|
" <td>0.538356</td>\n",
|
||
|
" <td>0.420548</td>\n",
|
||
|
" <td>0.365753</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4402</th>\n",
|
||
|
" <td>4601</td>\n",
|
||
|
" <td>-0.103077</td>\n",
|
||
|
" <td>-0.095819</td>\n",
|
||
|
" <td>-0.092537</td>\n",
|
||
|
" <td>0.062788</td>\n",
|
||
|
" <td>0.383562</td>\n",
|
||
|
" <td>-0.172337</td>\n",
|
||
|
" <td>-0.020589</td>\n",
|
||
|
" <td>-0.023368</td>\n",
|
||
|
" <td>-0.149273</td>\n",
|
||
|
" <td>-0.073525</td>\n",
|
||
|
" <td>-0.046937</td>\n",
|
||
|
" <td>-0.050252</td>\n",
|
||
|
" <td>-0.716935</td>\n",
|
||
|
" <td>-0.709322</td>\n",
|
||
|
" <td>-0.415359</td>\n",
|
||
|
" <td>-0.022089</td>\n",
|
||
|
" <td>0.335616</td>\n",
|
||
|
" <td>0.264384</td>\n",
|
||
|
" <td>0.401370</td>\n",
|
||
|
" <td>0.443836</td>\n",
|
||
|
" <td>0.447945</td>\n",
|
||
|
" <td>0.538356</td>\n",
|
||
|
" <td>0.420548</td>\n",
|
||
|
" <td>0.365753</td>\n",
|
||
|
" <td>0.352055</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4403</th>\n",
|
||
|
" <td>4602</td>\n",
|
||
|
" <td>-0.074527</td>\n",
|
||
|
" <td>-0.078431</td>\n",
|
||
|
" <td>-0.071642</td>\n",
|
||
|
" <td>0.080368</td>\n",
|
||
|
" <td>0.335616</td>\n",
|
||
|
" <td>-0.090165</td>\n",
|
||
|
" <td>-0.023565</td>\n",
|
||
|
" <td>-0.022924</td>\n",
|
||
|
" <td>-0.147587</td>\n",
|
||
|
" <td>-0.082629</td>\n",
|
||
|
" <td>-0.054747</td>\n",
|
||
|
" <td>-0.056542</td>\n",
|
||
|
" <td>-0.709344</td>\n",
|
||
|
" <td>-0.299248</td>\n",
|
||
|
" <td>-0.697161</td>\n",
|
||
|
" <td>-0.372758</td>\n",
|
||
|
" <td>0.264384</td>\n",
|
||
|
" <td>0.401370</td>\n",
|
||
|
" <td>0.443836</td>\n",
|
||
|
" <td>0.447945</td>\n",
|
||
|
" <td>0.538356</td>\n",
|
||
|
" <td>0.420548</td>\n",
|
||
|
" <td>0.365753</td>\n",
|
||
|
" <td>0.352055</td>\n",
|
||
|
" <td>0.284932</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4404</th>\n",
|
||
|
" <td>4603</td>\n",
|
||
|
" <td>-0.092696</td>\n",
|
||
|
" <td>-0.093230</td>\n",
|
||
|
" <td>-0.111194</td>\n",
|
||
|
" <td>0.038091</td>\n",
|
||
|
" <td>0.264384</td>\n",
|
||
|
" <td>-0.247492</td>\n",
|
||
|
" <td>-0.030463</td>\n",
|
||
|
" <td>-0.024164</td>\n",
|
||
|
" <td>-0.146390</td>\n",
|
||
|
" <td>-0.099513</td>\n",
|
||
|
" <td>-0.074158</td>\n",
|
||
|
" <td>-0.077581</td>\n",
|
||
|
" <td>-0.718980</td>\n",
|
||
|
" <td>-0.643250</td>\n",
|
||
|
" <td>-0.818783</td>\n",
|
||
|
" <td>-0.659348</td>\n",
|
||
|
" <td>0.401370</td>\n",
|
||
|
" <td>0.443836</td>\n",
|
||
|
" <td>0.447945</td>\n",
|
||
|
" <td>0.538356</td>\n",
|
||
|
" <td>0.420548</td>\n",
|
||
|
" <td>0.365753</td>\n",
|
||
|
" <td>0.352055</td>\n",
|
||
|
" <td>0.284932</td>\n",
|
||
|
" <td>0.328767</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" index Open High Low Adj Close Diff_Close RSI \\\n",
|
||
|
"4400 4599 -0.032629 -0.035886 -0.032090 0.134366 0.357534 0.135110 \n",
|
||
|
"4401 4600 -0.061550 -0.068073 -0.085821 0.077857 0.279452 -0.115170 \n",
|
||
|
"4402 4601 -0.103077 -0.095819 -0.092537 0.062788 0.383562 -0.172337 \n",
|
||
|
"4403 4602 -0.074527 -0.078431 -0.071642 0.080368 0.335616 -0.090165 \n",
|
||
|
"4404 4603 -0.092696 -0.093230 -0.111194 0.038091 0.264384 -0.247492 \n",
|
||
|
"\n",
|
||
|
" EMAF EMAM EMAS BBL_5_2.0 BBM_5_2.0 BBU_5_2.0 \\\n",
|
||
|
"4400 -0.011064 -0.023456 -0.152467 -0.007310 -0.014559 -0.050959 \n",
|
||
|
"4401 -0.015294 -0.023108 -0.150777 -0.047258 -0.029421 -0.041646 \n",
|
||
|
"4402 -0.020589 -0.023368 -0.149273 -0.073525 -0.046937 -0.050252 \n",
|
||
|
"4403 -0.023565 -0.022924 -0.147587 -0.082629 -0.054747 -0.056542 \n",
|
||
|
"4404 -0.030463 -0.024164 -0.146390 -0.099513 -0.074158 -0.077581 \n",
|
||
|
"\n",
|
||
|
" BBB_5_2.0 BBP_5_2.0 STOCHk_14_3_3 STOCHd_14_3_3 Target1 Target2 \\\n",
|
||
|
"4400 -0.884847 -0.358144 0.330323 0.488259 0.279452 0.383562 \n",
|
||
|
"4401 -0.762153 -0.905362 0.020945 0.291154 0.383562 0.335616 \n",
|
||
|
"4402 -0.716935 -0.709322 -0.415359 -0.022089 0.335616 0.264384 \n",
|
||
|
"4403 -0.709344 -0.299248 -0.697161 -0.372758 0.264384 0.401370 \n",
|
||
|
"4404 -0.718980 -0.643250 -0.818783 -0.659348 0.401370 0.443836 \n",
|
||
|
"\n",
|
||
|
" Target3 Target4 Target5 Target6 Target7 Target8 Target9 \n",
|
||
|
"4400 0.335616 0.264384 0.401370 0.443836 0.447945 0.538356 0.420548 \n",
|
||
|
"4401 0.264384 0.401370 0.443836 0.447945 0.538356 0.420548 0.365753 \n",
|
||
|
"4402 0.401370 0.443836 0.447945 0.538356 0.420548 0.365753 0.352055 \n",
|
||
|
"4403 0.443836 0.447945 0.538356 0.420548 0.365753 0.352055 0.284932 \n",
|
||
|
"4404 0.447945 0.538356 0.420548 0.365753 0.352055 0.284932 0.328767 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from sklearn.preprocessing import MinMaxScaler\n",
|
||
|
"sc = MinMaxScaler(feature_range=(-1,1))\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"df_scaled = sc.fit_transform(data_set.to_numpy())\n",
|
||
|
"data_set_scaled_pd = pd.DataFrame(df_scaled, columns=data_set.columns.tolist())\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"data_set_scaled_pd['index'] = data_set['index']\n",
|
||
|
"\n",
|
||
|
"data_set_scaled_pd.tail()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "99ca74fd",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Length of Data 4405\n",
|
||
|
"X Shape: (4385, 20, 16)\n",
|
||
|
"Y Shape: (4385, 9)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"X = []\n",
|
||
|
"\n",
|
||
|
"backcandles = 20\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"data_set_scaled = data_set_scaled_pd.to_numpy()\n",
|
||
|
"\n",
|
||
|
"print(\"Length of Data\", data_set_scaled.shape[0])\n",
|
||
|
"\n",
|
||
|
"features = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]\n",
|
||
|
"\n",
|
||
|
"feature_count = len(features)\n",
|
||
|
"\n",
|
||
|
"it = 0\n",
|
||
|
"for j in features:\n",
|
||
|
" X.append([])\n",
|
||
|
" for i in range(backcandles, data_set_scaled.shape[0]):\n",
|
||
|
" X[it].append(data_set_scaled[i-backcandles:i, j])\n",
|
||
|
" it += 1\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"X=np.moveaxis(X, [0], [2])\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"X = np.array(X)\n",
|
||
|
"\n",
|
||
|
"yi = np.array(data_set_scaled[backcandles:, -9:])\n",
|
||
|
"y=yi\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"print(\"X Shape:\", X.shape)\n",
|
||
|
"print(\"Y Shape:\", y.shape)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "a2a87918",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"4385\n",
|
||
|
"(4385, 20, 16)\n",
|
||
|
"(0, 20, 16)\n",
|
||
|
"(4385, 9)\n",
|
||
|
"(0, 9)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# split data into train test sets\n",
|
||
|
"splitlimit = int(len(X)*1)\n",
|
||
|
"print(splitlimit)\n",
|
||
|
"X_train, X_test = X[:splitlimit], X[splitlimit:]\n",
|
||
|
"y_train, y_test = y[:splitlimit], y[splitlimit:]\n",
|
||
|
"print(X_train.shape)\n",
|
||
|
"print(X_test.shape)\n",
|
||
|
"print(y_train.shape)\n",
|
||
|
"print(y_test.shape)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "9867161a",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"2024-10-07 19:55:07.650654: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
|
||
|
"2024-10-07 19:55:07.665948: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
|
||
|
"2024-10-07 19:55:07.670711: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
|
||
|
"2024-10-07 19:55:07.682482: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
|
||
|
"To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
|
||
|
"2024-10-07 19:55:08.294473: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"(4385, 20, 16)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
|
||
|
"I0000 00:00:1728345308.788157 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345308.833335 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345308.847700 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345308.857535 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345308.861197 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345308.869432 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345309.008330 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345309.009957 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1728345309.011379 164271 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"2024-10-07 19:55:09.013238: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2021] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1212 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3050, pci bus id: 0000:2d:00.0, compute capability: 8.6\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">Model: \"sequential\"</span>\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1mModel: \"sequential\"\u001b[0m\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
|
||
|
"┃<span style=\"font-weight: bold\"> Layer (type) </span>┃<span style=\"font-weight: bold\"> Output Shape </span>┃<span style=\"font-weight: bold\"> Param # </span>┃\n",
|
||
|
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
|
||
|
"│ dense (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">20</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">2,176</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_1 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">20</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">8,256</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_2 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">20</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">2,080</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dropout (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">20</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ flatten (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Flatten</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">640</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_layer (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">9</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">5,769</span> │\n",
|
||
|
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
|
||
|
"┃\u001b[1m \u001b[0m\u001b[1mLayer (type) \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m Param #\u001b[0m\u001b[1m \u001b[0m┃\n",
|
||
|
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
|
||
|
"│ dense (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m20\u001b[0m, \u001b[38;5;34m128\u001b[0m) │ \u001b[38;5;34m2,176\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_1 (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m20\u001b[0m, \u001b[38;5;34m64\u001b[0m) │ \u001b[38;5;34m8,256\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_2 (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m20\u001b[0m, \u001b[38;5;34m32\u001b[0m) │ \u001b[38;5;34m2,080\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dropout (\u001b[38;5;33mDropout\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m20\u001b[0m, \u001b[38;5;34m32\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ flatten (\u001b[38;5;33mFlatten\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m640\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense_layer (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m9\u001b[0m) │ \u001b[38;5;34m5,769\u001b[0m │\n",
|
||
|
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Total params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">18,281</span> (71.41 KB)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Total params: \u001b[0m\u001b[38;5;34m18,281\u001b[0m (71.41 KB)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">18,281</span> (71.41 KB)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Trainable params: \u001b[0m\u001b[38;5;34m18,281\u001b[0m (71.41 KB)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Non-trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> (0.00 B)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Non-trainable params: \u001b[0m\u001b[38;5;34m0\u001b[0m (0.00 B)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
|
||
|
"I0000 00:00:1728345310.384833 164347 service.cc:146] XLA service 0x7c45a00043e0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:\n",
|
||
|
"I0000 00:00:1728345310.384862 164347 service.cc:154] StreamExecutor device (0): NVIDIA GeForce RTX 3050, Compute Capability 8.6\n",
|
||
|
"2024-10-07 19:55:10.434223: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:268] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.\n",
|
||
|
"2024-10-07 19:55:10.569875: I external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:531] Loaded cuDNN version 8907\n",
|
||
|
"I0000 00:00:1728345315.348810 164347 device_compiler.h:188] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.\n",
|
||
|
"2024-10-07 19:55:21.210858: I external/local_xla/xla/stream_executor/cuda/cuda_asm_compiler.cc:393] ptxas warning : Registers are spilled to local memory in function 'gemm_fusion_dot_41', 96 bytes spill stores, 96 bytes spill loads\n",
|
||
|
"\n",
|
||
|
"2024-10-07 19:55:23.138934: I external/local_xla/xla/stream_executor/cuda/cuda_asm_compiler.cc:393] ptxas warning : Registers are spilled to local memory in function 'gemm_fusion_dot_41', 92 bytes spill stores, 92 bytes spill loads\n",
|
||
|
"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from keras.models import Sequential\n",
|
||
|
"from keras.layers import LSTM\n",
|
||
|
"from keras.layers import Dropout\n",
|
||
|
"from keras.layers import Dense\n",
|
||
|
"from keras.layers import TimeDistributed\n",
|
||
|
"\n",
|
||
|
"import tensorflow as tf\n",
|
||
|
"import keras\n",
|
||
|
"from keras import optimizers\n",
|
||
|
"from keras.callbacks import History\n",
|
||
|
"from keras.models import Model\n",
|
||
|
"from keras.layers import Dense, Dropout, LSTM, Input, Activation, concatenate\n",
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"from tensorflow.keras.models import Sequential\n",
|
||
|
"from tensorflow.keras.optimizers import Adam\n",
|
||
|
"from tensorflow.keras import layers\n",
|
||
|
"np.random.seed(10)\n",
|
||
|
"print(X_train.shape)\n",
|
||
|
"\n",
|
||
|
"model = Sequential([layers.Input((backcandles, feature_count)),\n",
|
||
|
" layers.Dense(128, activation='relu'),\n",
|
||
|
" layers.Dense(64, activation='relu'),\n",
|
||
|
" layers.Dense(32, activation='relu'),\n",
|
||
|
" layers.Dropout(0.2),\n",
|
||
|
" layers.Flatten(),\n",
|
||
|
" layers.Dense(9, name='dense_layer', activation='tanh')])\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"model.compile(loss='mse', \n",
|
||
|
" optimizer=Adam(learning_rate=0.001),\n",
|
||
|
" metrics=['mean_absolute_error'])\n",
|
||
|
"\n",
|
||
|
"model.summary()\n",
|
||
|
"\n",
|
||
|
"epochs=2400\n",
|
||
|
"history = model.fit(x=X_train, y=y_train, batch_size=15, epochs=epochs, shuffle=True, validation_split = 0.2, verbose=0)\n",
|
||
|
"\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "7e2b61f1-032f-43b5-a457-d6835076b7f8",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<contextlib.ExitStack at 0x7c46a9d69960>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6AAAAHBCAYAAAB38tZnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADYYUlEQVR4nOzdd3QUVRsG8GfTCYHQkyCptIQOATFABKRJUVAUUAhSpSmEiNJFQQSUkg+lCAYQUYjSVUCCVCUiXYEIKCUIiTRJgEDqfH8Mu9kyuzuzNQnP75w92Z29M3O3ZGfeufe+VyUIggAiIiIiIiIiO3NxdgWIiIiIiIjo8cAAlIiIiIiIiByCASgRERERERE5BANQIiIiIiIicggGoEREREREROQQDECJiIiIiIjIIRiAEhERERERkUMwACUiIiIiIiKHYABKREREREREDsEAtBhSqVSybnv37rVqP++99x5UKpVF6+7du9cmdSjq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zdVWALh+/TqGDx+OwMBATb2Dg4MByPtstO3ZswcA0LdvX53lr776qkHZvLw8fPjhh6hTpw48PDzg5uYGDw8PnD9/XvF+9fc/YMAAneVPPvkkIiIi8NNPP+ks9/f3x5NPPqmzTP+7Ycy+ffvw119/4bXXXtN8lupuSdrd0ZKSkpCfn2+yNfDgwYPIzMzEyJEjbZpF8Pnnn4e7u7vB8m+//RYtW7aEj4+P5jNPSEjQed+3b98OAGZbMceMGYMTJ07gl19+ASB2+fr
|
||
|
"text/plain": [
|
||
|
"<Figure size 1100x500 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"history = model.fit(x=X_train, y=y_train, batch_size=15, epochs=epochs, shuffle=True, validation_split = 0.2, verbose=0)\n",
|
||
|
"\n",
|
||
|
"acc = history.history['mean_absolute_error']\n",
|
||
|
"val_acc = history.history['val_mean_absolute_error']\n",
|
||
|
"\n",
|
||
|
"loss = history.history['loss']\n",
|
||
|
"val_loss = history.history['val_loss']\n",
|
||
|
"\n",
|
||
|
"epochs_range = range(epochs)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(11, 5))\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.plot(epochs_range, acc, label='Training Accuracy')\n",
|
||
|
"plt.plot(epochs_range, val_acc, label='Validation Accuracy')\n",
|
||
|
"plt.legend(loc='lower right')\n",
|
||
|
"plt.title('Training and Validation Accuracy')\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.plot(epochs_range, loss, label='Training Loss')\n",
|
||
|
"plt.plot(epochs_range, val_loss, label='Validation Loss')\n",
|
||
|
"plt.legend(loc='upper right')\n",
|
||
|
"plt.title('Training and Validation Loss')\n",
|
||
|
"plt.ion()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "08324ede",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"2024-10-07 20:14:04.453124: I external/local_xla/xla/stream_executor/cuda/cuda_asm_compiler.cc:393] ptxas warning : Registers are spilled to local memory in function 'gemm_fusion_dot_33', 36 bytes spill stores, 36 bytes spill loads\n",
|
||
|
"\n",
|
||
|
"2024-10-07 20:14:04.563263: I external/local_xla/xla/stream_executor/cuda/cuda_asm_compiler.cc:393] ptxas warning : Registers are spilled to local memory in function 'gemm_fusion_dot_33', 360 bytes spill stores, 360 bytes spill loads\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\u001b[1m138/138\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m3s\u001b[0m 7ms/step\n",
|
||
|
"Pridicted: [-0.36162856 -0.43332186 -0.3523488 -0.28136992 -0.3563385 -0.41920266\n",
|
||
|
" -0.40086812 -0.40910283 -0.38491216] Real value: [-0.40136986 -0.46164384 -0.35342466 -0.27945205 -0.34931507 -0.43013699\n",
|
||
|
" -0.42739726 -0.41369863 -0.39726027]\n",
|
||
|
"Pridicted: [-0.4348482 -0.35673153 -0.28561482 -0.349432 -0.43765935 -0.4265165\n",
|
||
|
" -0.40560463 -0.3999594 -0.3821063 ] Real value: [-0.46164384 -0.35342466 -0.27945205 -0.34931507 -0.43013699 -0.42739726\n",
|
||
|
" -0.41369863 -0.39726027 -0.41780822]\n",
|
||
|
"Pridicted: [-0.38370562 -0.2812817 -0.340804 -0.41657993 -0.416808 -0.40895227\n",
|
||
|
" -0.39119083 -0.39400247 -0.41795033] Real value: [-0.35342466 -0.27945205 -0.34931507 -0.43013699 -0.42739726 -0.41369863\n",
|
||
|
" -0.39726027 -0.41780822 -0.42328767]\n",
|
||
|
"Pridicted: [-0.29063264 -0.34499377 -0.4208798 -0.40789008 -0.40698296 -0.4131924\n",
|
||
|
" -0.38356876 -0.44646472 -0.37091735] Real value: [-0.27945205 -0.34931507 -0.43013699 -0.42739726 -0.41369863 -0.39726027\n",
|
||
|
" -0.41780822 -0.42328767 -0.36027397]\n",
|
||
|
"Pridicted: [-0.3494526 -0.4203193 -0.40559536 -0.3937887 -0.41101933 -0.39652374\n",
|
||
|
" -0.42679134 -0.38282433 -0.39217785] Real value: [-0.34931507 -0.43013699 -0.42739726 -0.41369863 -0.39726027 -0.41780822\n",
|
||
|
" -0.42328767 -0.36027397 -0.42054795]\n",
|
||
|
"Pridicted: [-0.42891395 -0.40761665 -0.39522445 -0.3996233 -0.40153465 -0.44026577\n",
|
||
|
" -0.3772592 -0.40035576 -0.35613042] Real value: [-0.43013699 -0.42739726 -0.41369863 -0.39726027 -0.41780822 -0.42328767\n",
|
||
|
" -0.36027397 -0.42054795 -0.32739726]\n",
|
||
|
"Pridicted: [-0.40219325 -0.38756976 -0.39211658 -0.3793638 -0.4407541 -0.38048762\n",
|
||
|
" -0.3906664 -0.34461808 -0.45740467] Real value: [-0.42739726 -0.41369863 -0.39726027 -0.41780822 -0.42328767 -0.36027397\n",
|
||
|
" -0.42054795 -0.32739726 -0.45205479]\n",
|
||
|
"Pridicted: [-0.3997392 -0.4036399 -0.38481608 -0.43141615 -0.39609036 -0.40770343\n",
|
||
|
" -0.3379205 -0.4757088 -0.30856273] Real value: [-0.41369863 -0.39726027 -0.41780822 -0.42328767 -0.36027397 -0.42054795\n",
|
||
|
" -0.32739726 -0.45205479 -0.35342466]\n",
|
||
|
"Pridicted: [-0.39815712 -0.38647228 -0.43177652 -0.372594 -0.4144538 -0.3646657\n",
|
||
|
" -0.47009906 -0.3289713 -0.21806642] Real value: [-0.39726027 -0.41780822 -0.42328767 -0.36027397 -0.42054795 -0.32739726\n",
|
||
|
" -0.45205479 -0.35342466 -0.18767123]\n",
|
||
|
"Pridicted: [-0.3795808 -0.433394 -0.37585306 -0.40730223 -0.35770226 -0.4803442\n",
|
||
|
" -0.31476918 -0.2233371 -0.30246612] Real value: [-0.41780822 -0.42328767 -0.36027397 -0.42054795 -0.32739726 -0.45205479\n",
|
||
|
" -0.35342466 -0.18767123 -0.31643836]\n",
|
||
|
"\n",
|
||
|
"[0.40136986 0.44383562 0.44794521 0.53835616 0.42054795 0.36575342\n",
|
||
|
" 0.35205479 0.28493151 0.32876712]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"y_pred = model.predict(X_train)\n",
|
||
|
"for i in range(10):\n",
|
||
|
" print(\"Pridicted:\", y_pred[i], \"Real value:\", y_train[i])\n",
|
||
|
"print()\n",
|
||
|
"print(f\"{y_train[-1]}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "67f5e31a",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<contextlib.ExitStack at 0x7c46a81eb1c0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA08AAAGsCAYAAAAFcZwfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACc7klEQVR4nOzdeViU5f7H8fewyqLjguCGoqLinpp7LimCldlimpm022qr9evUqY4t59Q5LbYvmm1k2ablFiJuueFOpiLuWwqiIsgOM/P74xGM3EAZngE+r+uay2HmeZ75jht85r7v721xOBwORERERERE5LzczC5ARERERESkMlB4EhERERERKQWFJxERERERkVJQeBIRERERESkFhScREREREZFSUHgSEREREREpB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fXUhICK+88gp33HEHVquVcePGAbBy5Ur69++Pj48PwcHBPPLII2RlZRVf98iRI1x77bX4+PjQvHlzpk2bVmHvSeFJRESqFlsubHsbgMRGY5m++Tvg3KNORYpbluf5GQ9o6p6IuCiHw0FWfpYpt7I26v7yyy/x8PBg9erVvPvuu0yaNIlPP/20+PnXX3+dDh06sH79ep5//nn++OMPIiMjufHGG9m0aRPfffcdy5cvZ/z48cXn3HHHHezdu5dFixbx448/8uGHH3LkyJFy+/09H/VhFRGRqmVPNOQmg28TXt71Ow4cXB92/TlHnYpEtozkmYXPsDgtmfxa4KWmESL
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.figure(figsize=(10,5))\n",
|
||
|
"plt.plot(y_train[100], color = 'orange', label = 'real')\n",
|
||
|
"plt.plot(y_pred[100], color = 'green', label = 'pred')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.ion()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "b76d089d-356a-4f9c-9a94-3d00671e8f4d",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Save Model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "71f7fd19-5a06-40ae-bc25-fab6e2aa08bc",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"model.save(\"models/\" + name + \".keras\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "8b953033-d9e2-417d-bf5f-e3c2b401a2b2",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"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.10.14"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|