precipitation-pl/solution.ipynb
2022-05-22 20:32:15 +02:00

2210 lines
78 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 316,
"id": "ddcaf12b",
"metadata": {},
"outputs": [],
"source": [
"# Import required libraries\n",
"import pandas as pd\n",
"import numpy as np \n",
"import matplotlib.pyplot as plt\n",
"import sklearn\n",
"\n",
"# Import necessary modules\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.metrics import mean_squared_error\n",
"from math import sqrt\n",
"\n",
"# Keras specific\n",
"import keras\n",
"from keras.models import Sequential\n",
"from keras.layers import Dense"
]
},
{
"cell_type": "code",
"execution_count": 317,
"id": "70e3b6e3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8760"
]
},
"execution_count": 317,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"in_columns = ['id_stacji', 'nazwa_stacji', 'typ_zbioru', 'rok', 'miesiąc']\n",
"\n",
"df = pd.read_csv('train/in.tsv', names=in_columns, sep='\\t')\n",
"len(df)"
]
},
{
"cell_type": "code",
"execution_count": 318,
"id": "44f404d6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"720"
]
},
"execution_count": 318,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_test = pd.read_csv('test-A/in.tsv', names=in_columns, sep='\\t')\n",
"len(df_test)"
]
},
{
"cell_type": "code",
"execution_count": 319,
"id": "c760402a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9480"
]
},
"execution_count": 319,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.concat([df,df_test])\n",
"len(df)"
]
},
{
"cell_type": "code",
"execution_count": 320,
"id": "06f39e15",
"metadata": {},
"outputs": [],
"source": [
"df = df.drop(['nazwa_stacji','typ_zbioru'], axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 321,
"id": "91c047f6",
"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>id_stacji_249180010</th>\n",
" <th>id_stacji_249190560</th>\n",
" <th>id_stacji_249200370</th>\n",
" <th>id_stacji_249200490</th>\n",
" <th>id_stacji_249220150</th>\n",
" <th>id_stacji_249220180</th>\n",
" <th>id_stacji_250190160</th>\n",
" <th>id_stacji_250190390</th>\n",
" <th>id_stacji_250210130</th>\n",
" <th>id_stacji_251170090</th>\n",
" <th>...</th>\n",
" <th>miesiąc_3</th>\n",
" <th>miesiąc_4</th>\n",
" <th>miesiąc_5</th>\n",
" <th>miesiąc_6</th>\n",
" <th>miesiąc_7</th>\n",
" <th>miesiąc_8</th>\n",
" <th>miesiąc_9</th>\n",
" <th>miesiąc_10</th>\n",
" <th>miesiąc_11</th>\n",
" <th>miesiąc_12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>715</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>716</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>717</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>718</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>719</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>9480 rows × 73 columns</p>\n",
"</div>"
],
"text/plain": [
" id_stacji_249180010 id_stacji_249190560 id_stacji_249200370 \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 1 0 0 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_249200490 id_stacji_249220150 id_stacji_249220180 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_250190160 id_stacji_250190390 id_stacji_250210130 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_251170090 ... miesiąc_3 miesiąc_4 miesiąc_5 miesiąc_6 \\\n",
"0 0 ... 0 0 0 0 \n",
"1 0 ... 0 0 0 0 \n",
"2 0 ... 1 0 0 0 \n",
"3 0 ... 0 1 0 0 \n",
"4 0 ... 0 0 1 0 \n",
".. ... ... ... ... ... ... \n",
"715 0 ... 0 0 0 0 \n",
"716 0 ... 0 0 0 0 \n",
"717 0 ... 0 0 0 0 \n",
"718 0 ... 0 0 0 0 \n",
"719 0 ... 0 0 0 0 \n",
"\n",
" miesiąc_7 miesiąc_8 miesiąc_9 miesiąc_10 miesiąc_11 miesiąc_12 \n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
".. ... ... ... ... ... ... \n",
"715 0 1 0 0 0 0 \n",
"716 0 0 1 0 0 0 \n",
"717 0 0 0 1 0 0 \n",
"718 0 0 0 0 1 0 \n",
"719 0 0 0 0 0 1 \n",
"\n",
"[9480 rows x 73 columns]"
]
},
"execution_count": 321,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = pd.get_dummies(df,columns = ['id_stacji','rok','miesiąc'])\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": 322,
"id": "037f1315",
"metadata": {},
"outputs": [],
"source": [
"x = x.iloc[:-720]"
]
},
{
"cell_type": "code",
"execution_count": 323,
"id": "e03bae07",
"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>id_stacji_249180010</th>\n",
" <th>id_stacji_249190560</th>\n",
" <th>id_stacji_249200370</th>\n",
" <th>id_stacji_249200490</th>\n",
" <th>id_stacji_249220150</th>\n",
" <th>id_stacji_249220180</th>\n",
" <th>id_stacji_250190160</th>\n",
" <th>id_stacji_250190390</th>\n",
" <th>id_stacji_250210130</th>\n",
" <th>id_stacji_251170090</th>\n",
" <th>...</th>\n",
" <th>miesiąc_3</th>\n",
" <th>miesiąc_4</th>\n",
" <th>miesiąc_5</th>\n",
" <th>miesiąc_6</th>\n",
" <th>miesiąc_7</th>\n",
" <th>miesiąc_8</th>\n",
" <th>miesiąc_9</th>\n",
" <th>miesiąc_10</th>\n",
" <th>miesiąc_11</th>\n",
" <th>miesiąc_12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8755</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8756</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8757</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8758</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8759</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>8760 rows × 73 columns</p>\n",
"</div>"
],
"text/plain": [
" id_stacji_249180010 id_stacji_249190560 id_stacji_249200370 \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 1 0 0 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_249200490 id_stacji_249220150 id_stacji_249220180 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_250190160 id_stacji_250190390 id_stacji_250210130 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_251170090 ... miesiąc_3 miesiąc_4 miesiąc_5 miesiąc_6 \\\n",
"0 0 ... 0 0 0 0 \n",
"1 0 ... 0 0 0 0 \n",
"2 0 ... 1 0 0 0 \n",
"3 0 ... 0 1 0 0 \n",
"4 0 ... 0 0 1 0 \n",
"... ... ... ... ... ... ... \n",
"8755 0 ... 0 0 0 0 \n",
"8756 0 ... 0 0 0 0 \n",
"8757 0 ... 0 0 0 0 \n",
"8758 0 ... 0 0 0 0 \n",
"8759 0 ... 0 0 0 0 \n",
"\n",
" miesiąc_7 miesiąc_8 miesiąc_9 miesiąc_10 miesiąc_11 miesiąc_12 \n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
"... ... ... ... ... ... ... \n",
"8755 0 1 0 0 0 0 \n",
"8756 0 0 1 0 0 0 \n",
"8757 0 0 0 1 0 0 \n",
"8758 0 0 0 0 1 0 \n",
"8759 0 0 0 0 0 1 \n",
"\n",
"[8760 rows x 73 columns]"
]
},
"execution_count": 323,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x"
]
},
{
"cell_type": "code",
"execution_count": 324,
"id": "ede98181",
"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>rainfall</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>19.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>43.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>72.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>25.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>89.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8755</th>\n",
" <td>114.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8756</th>\n",
" <td>101.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8757</th>\n",
" <td>20.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8758</th>\n",
" <td>93.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8759</th>\n",
" <td>46.9</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>8760 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" rainfall\n",
"0 19.4\n",
"1 43.2\n",
"2 72.2\n",
"3 25.3\n",
"4 89.3\n",
"... ...\n",
"8755 114.9\n",
"8756 101.2\n",
"8757 20.4\n",
"8758 93.2\n",
"8759 46.9\n",
"\n",
"[8760 rows x 1 columns]"
]
},
"execution_count": 324,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y = pd.read_csv('train/expected.tsv', sep='\\t', names=['rainfall'])\n",
"#y = np.array(y).reshape(1,-1)\n",
"y"
]
},
{
"cell_type": "code",
"execution_count": 325,
"id": "9a950571",
"metadata": {},
"outputs": [],
"source": [
"# Define model\n",
"model = Sequential()\n",
"model.add(Dense(1024, input_dim=73, activation= \"relu\"))\n",
"model.add(Dense(512, activation= \"relu\"))\n",
"model.add(Dense(256, activation= \"relu\"))\n",
"model.add(Dense(128, activation= \"relu\"))\n",
"model.add(Dense(64, activation= \"relu\"))\n",
"model.add(Dense(32, activation= \"relu\"))\n",
"model.add(Dense(16, activation= \"relu\"))\n",
"model.add(Dense(1))\n",
"#model.summary() #Print model Summary"
]
},
{
"cell_type": "code",
"execution_count": 326,
"id": "f68e43f9",
"metadata": {},
"outputs": [],
"source": [
"df['id_stacji'] = np.asarray(df['id_stacji']).astype('float32')\n",
"df['rok'] = np.asarray(df['rok']).astype('float32')\n",
"df['miesiąc'] = np.asarray(df['miesiąc']).astype('float32')"
]
},
{
"cell_type": "code",
"execution_count": 327,
"id": "c1036c04",
"metadata": {},
"outputs": [],
"source": [
"y = np.asarray(y).astype('float32')"
]
},
{
"cell_type": "code",
"execution_count": 328,
"id": "cec44474",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(None, 73) <dtype: 'float32'>\n",
"(None, 1) <dtype: 'float32'>\n",
"dense_103 (None, 73) float32\n",
"dense_104 (None, 1024) float32\n",
"dense_105 (None, 512) float32\n",
"dense_106 (None, 256) float32\n",
"dense_107 (None, 128) float32\n",
"dense_108 (None, 64) float32\n",
"dense_109 (None, 32) float32\n",
"dense_110 (None, 16) float32\n"
]
},
{
"data": {
"text/plain": [
"[None, None, None, None, None, None, None, None]"
]
},
"execution_count": 328,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[print(i.shape, i.dtype) for i in model.inputs]\n",
"[print(o.shape, o.dtype) for o in model.outputs]\n",
"[print(l.name, l.input_shape, l.dtype) for l in model.layers]"
]
},
{
"cell_type": "code",
"execution_count": 329,
"id": "eb9cb318",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 1148.3020 - mean_squared_error: 1148.3020\n",
"Epoch 2/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 763.9616 - mean_squared_error: 763.9616\n",
"Epoch 3/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 545.3013 - mean_squared_error: 545.3013\n",
"Epoch 4/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 461.5141 - mean_squared_error: 461.5141\n",
"Epoch 5/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 422.0508 - mean_squared_error: 422.0508\n",
"Epoch 6/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 391.7643 - mean_squared_error: 391.7643\n",
"Epoch 7/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 331.7844 - mean_squared_error: 331.7844\n",
"Epoch 8/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 301.6153 - mean_squared_error: 301.6153\n",
"Epoch 9/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 260.0949 - mean_squared_error: 260.0949\n",
"Epoch 10/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 224.1433 - mean_squared_error: 224.1433\n",
"Epoch 11/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 201.2247 - mean_squared_error: 201.2247\n",
"Epoch 12/80\n",
"274/274 [==============================] - 1s 5ms/step - loss: 170.9166 - mean_squared_error: 170.9166\n",
"Epoch 13/80\n",
"274/274 [==============================] - 1s 5ms/step - loss: 139.1919 - mean_squared_error: 139.1919\n",
"Epoch 14/80\n",
"274/274 [==============================] - 1s 5ms/step - loss: 115.9581 - mean_squared_error: 115.9581\n",
"Epoch 15/80\n",
"274/274 [==============================] - 1s 5ms/step - loss: 103.9778 - mean_squared_error: 103.9778\n",
"Epoch 16/80\n",
"274/274 [==============================] - 1s 5ms/step - loss: 88.2708 - mean_squared_error: 88.2708\n",
"Epoch 17/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 72.0225 - mean_squared_error: 72.0225\n",
"Epoch 18/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 63.5714 - mean_squared_error: 63.5714\n",
"Epoch 19/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 56.0757 - mean_squared_error: 56.0757\n",
"Epoch 20/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 52.9535 - mean_squared_error: 52.9535\n",
"Epoch 21/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 50.0143 - mean_squared_error: 50.0143\n",
"Epoch 22/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 41.2315 - mean_squared_error: 41.2315\n",
"Epoch 23/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 39.8365 - mean_squared_error: 39.8365\n",
"Epoch 24/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 41.5614 - mean_squared_error: 41.5614\n",
"Epoch 25/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 42.3862 - mean_squared_error: 42.3862\n",
"Epoch 26/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 38.0177 - mean_squared_error: 38.0177\n",
"Epoch 27/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 36.0990 - mean_squared_error: 36.0990\n",
"Epoch 28/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 41.5000 - mean_squared_error: 41.5000\n",
"Epoch 29/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 37.8813 - mean_squared_error: 37.8813\n",
"Epoch 30/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 37.9894 - mean_squared_error: 37.9894\n",
"Epoch 31/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 31.0013 - mean_squared_error: 31.0013\n",
"Epoch 32/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 24.9764 - mean_squared_error: 24.9764\n",
"Epoch 33/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 31.9433 - mean_squared_error: 31.9433\n",
"Epoch 34/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 31.7013 - mean_squared_error: 31.7013\n",
"Epoch 35/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 29.5324 - mean_squared_error: 29.5324\n",
"Epoch 36/80\n",
"274/274 [==============================] - 2s 5ms/step - loss: 32.4733 - mean_squared_error: 32.4733\n",
"Epoch 37/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 23.7742 - mean_squared_error: 23.7742\n",
"Epoch 38/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 27.0307 - mean_squared_error: 27.0307\n",
"Epoch 39/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 28.7847 - mean_squared_error: 28.7847\n",
"Epoch 40/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 31.0826 - mean_squared_error: 31.0826\n",
"Epoch 41/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 26.5976 - mean_squared_error: 26.5976\n",
"Epoch 42/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 24.3899 - mean_squared_error: 24.3899\n",
"Epoch 43/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 20.7662 - mean_squared_error: 20.7662\n",
"Epoch 44/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.0226 - mean_squared_error: 19.0226\n",
"Epoch 45/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.3724 - mean_squared_error: 19.3724\n",
"Epoch 46/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 24.7011 - mean_squared_error: 24.7011\n",
"Epoch 47/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 25.1954 - mean_squared_error: 25.1954\n",
"Epoch 48/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 29.5989 - mean_squared_error: 29.5989\n",
"Epoch 49/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 22.7573 - mean_squared_error: 22.7573\n",
"Epoch 50/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 23.1566 - mean_squared_error: 23.1566\n",
"Epoch 51/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 18.3705 - mean_squared_error: 18.3705\n",
"Epoch 52/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 16.7029 - mean_squared_error: 16.7029\n",
"Epoch 53/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 16.9602 - mean_squared_error: 16.9602\n",
"Epoch 54/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 21.2996 - mean_squared_error: 21.2996\n",
"Epoch 55/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.7800 - mean_squared_error: 19.7800\n",
"Epoch 56/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.7060 - mean_squared_error: 19.7060\n",
"Epoch 57/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 20.6657 - mean_squared_error: 20.6657\n",
"Epoch 58/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.9114 - mean_squared_error: 19.9114\n",
"Epoch 59/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 15.5104 - mean_squared_error: 15.5104\n",
"Epoch 60/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 14.6696 - mean_squared_error: 14.6696\n",
"Epoch 61/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 15.2659 - mean_squared_error: 15.2659\n",
"Epoch 62/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 18.6857 - mean_squared_error: 18.6857\n",
"Epoch 63/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 19.9120 - mean_squared_error: 19.9120\n",
"Epoch 64/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 22.7588 - mean_squared_error: 22.7588\n",
"Epoch 65/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 18.3624 - mean_squared_error: 18.3624\n",
"Epoch 66/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.8439 - mean_squared_error: 19.8439\n",
"Epoch 67/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 15.1439 - mean_squared_error: 15.1439\n",
"Epoch 68/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 14.6623 - mean_squared_error: 14.6623\n",
"Epoch 69/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 14.0223 - mean_squared_error: 14.0223\n",
"Epoch 70/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 20.7763 - mean_squared_error: 20.7763\n",
"Epoch 71/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 19.1875 - mean_squared_error: 19.1875\n",
"Epoch 72/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 14.1436 - mean_squared_error: 14.1436\n",
"Epoch 73/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 14.2062 - mean_squared_error: 14.2062\n",
"Epoch 74/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 10.8038 - mean_squared_error: 10.8038\n",
"Epoch 75/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 10.9576 - mean_squared_error: 10.9576\n",
"Epoch 76/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 12.1856 - mean_squared_error: 12.1856\n",
"Epoch 77/80\n",
"274/274 [==============================] - 2s 7ms/step - loss: 12.5274 - mean_squared_error: 12.5274\n",
"Epoch 78/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 14.9551 - mean_squared_error: 14.9551\n",
"Epoch 79/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 15.9294 - mean_squared_error: 15.9294\n",
"Epoch 80/80\n",
"274/274 [==============================] - 2s 6ms/step - loss: 16.6070 - mean_squared_error: 16.6070\n"
]
},
{
"data": {
"text/plain": [
"<keras.callbacks.History at 0x20e7057ed30>"
]
},
"execution_count": 329,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.compile(loss= \"mean_squared_error\" , optimizer=\"adam\", metrics=[\"mean_squared_error\"])\n",
"model.fit(x, y, epochs=80)"
]
},
{
"cell_type": "code",
"execution_count": 330,
"id": "bad4d35a",
"metadata": {},
"outputs": [],
"source": [
"x_test = pd.read_csv('test-A/in.tsv', sep='\\t', names=in_columns)\n",
"#y_test = pd.read_csv('test-A/expected.tsv', sep='\\t',names=['rainfall'])\n",
"#x_test = x_test.drop(['nazwa_stacji', 'typ_zbioru'],axis=1)\n",
"df_train = pd.read_csv('train/in.tsv', names=in_columns, sep='\\t')"
]
},
{
"cell_type": "code",
"execution_count": 331,
"id": "a3b6fff0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9480"
]
},
"execution_count": 331,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x_test = pd.concat([x_test,df_train])\n",
"len(x_test)"
]
},
{
"cell_type": "code",
"execution_count": 332,
"id": "cdf89362",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9480"
]
},
"execution_count": 332,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x_test = x_test.drop(['nazwa_stacji', 'typ_zbioru'],axis=1)\n",
"len(x_test)"
]
},
{
"cell_type": "code",
"execution_count": 333,
"id": "fe00b876",
"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>id_stacji_249180010</th>\n",
" <th>id_stacji_249190560</th>\n",
" <th>id_stacji_249200370</th>\n",
" <th>id_stacji_249200490</th>\n",
" <th>id_stacji_249220150</th>\n",
" <th>id_stacji_249220180</th>\n",
" <th>id_stacji_250190160</th>\n",
" <th>id_stacji_250190390</th>\n",
" <th>id_stacji_250210130</th>\n",
" <th>id_stacji_251170090</th>\n",
" <th>...</th>\n",
" <th>miesiąc_3</th>\n",
" <th>miesiąc_4</th>\n",
" <th>miesiąc_5</th>\n",
" <th>miesiąc_6</th>\n",
" <th>miesiąc_7</th>\n",
" <th>miesiąc_8</th>\n",
" <th>miesiąc_9</th>\n",
" <th>miesiąc_10</th>\n",
" <th>miesiąc_11</th>\n",
" <th>miesiąc_12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8755</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8756</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8757</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8758</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8759</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>9480 rows × 73 columns</p>\n",
"</div>"
],
"text/plain": [
" id_stacji_249180010 id_stacji_249190560 id_stacji_249200370 \\\n",
"0 0 0 1 \n",
"1 0 0 1 \n",
"2 0 0 1 \n",
"3 0 0 1 \n",
"4 0 0 1 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_249200490 id_stacji_249220150 id_stacji_249220180 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_250190160 id_stacji_250190390 id_stacji_250210130 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
"... ... ... ... \n",
"8755 0 0 0 \n",
"8756 0 0 0 \n",
"8757 0 0 0 \n",
"8758 0 0 0 \n",
"8759 0 0 0 \n",
"\n",
" id_stacji_251170090 ... miesiąc_3 miesiąc_4 miesiąc_5 miesiąc_6 \\\n",
"0 0 ... 0 0 0 0 \n",
"1 0 ... 0 0 0 0 \n",
"2 0 ... 1 0 0 0 \n",
"3 0 ... 0 1 0 0 \n",
"4 0 ... 0 0 1 0 \n",
"... ... ... ... ... ... ... \n",
"8755 0 ... 0 0 0 0 \n",
"8756 0 ... 0 0 0 0 \n",
"8757 0 ... 0 0 0 0 \n",
"8758 0 ... 0 0 0 0 \n",
"8759 0 ... 0 0 0 0 \n",
"\n",
" miesiąc_7 miesiąc_8 miesiąc_9 miesiąc_10 miesiąc_11 miesiąc_12 \n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
"... ... ... ... ... ... ... \n",
"8755 0 1 0 0 0 0 \n",
"8756 0 0 1 0 0 0 \n",
"8757 0 0 0 1 0 0 \n",
"8758 0 0 0 0 1 0 \n",
"8759 0 0 0 0 0 1 \n",
"\n",
"[9480 rows x 73 columns]"
]
},
"execution_count": 333,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x_test = pd.get_dummies(x_test,columns = ['id_stacji','rok','miesiąc'])\n",
"x_test"
]
},
{
"cell_type": "code",
"execution_count": 334,
"id": "657a7976",
"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>id_stacji_249180010</th>\n",
" <th>id_stacji_249190560</th>\n",
" <th>id_stacji_249200370</th>\n",
" <th>id_stacji_249200490</th>\n",
" <th>id_stacji_249220150</th>\n",
" <th>id_stacji_249220180</th>\n",
" <th>id_stacji_250190160</th>\n",
" <th>id_stacji_250190390</th>\n",
" <th>id_stacji_250210130</th>\n",
" <th>id_stacji_251170090</th>\n",
" <th>...</th>\n",
" <th>miesiąc_3</th>\n",
" <th>miesiąc_4</th>\n",
" <th>miesiąc_5</th>\n",
" <th>miesiąc_6</th>\n",
" <th>miesiąc_7</th>\n",
" <th>miesiąc_8</th>\n",
" <th>miesiąc_9</th>\n",
" <th>miesiąc_10</th>\n",
" <th>miesiąc_11</th>\n",
" <th>miesiąc_12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>715</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>716</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>717</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>718</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>719</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>720 rows × 73 columns</p>\n",
"</div>"
],
"text/plain": [
" id_stacji_249180010 id_stacji_249190560 id_stacji_249200370 \\\n",
"0 0 0 1 \n",
"1 0 0 1 \n",
"2 0 0 1 \n",
"3 0 0 1 \n",
"4 0 0 1 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_249200490 id_stacji_249220150 id_stacji_249220180 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_250190160 id_stacji_250190390 id_stacji_250210130 \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
".. ... ... ... \n",
"715 0 0 0 \n",
"716 0 0 0 \n",
"717 0 0 0 \n",
"718 0 0 0 \n",
"719 0 0 0 \n",
"\n",
" id_stacji_251170090 ... miesiąc_3 miesiąc_4 miesiąc_5 miesiąc_6 \\\n",
"0 0 ... 0 0 0 0 \n",
"1 0 ... 0 0 0 0 \n",
"2 0 ... 1 0 0 0 \n",
"3 0 ... 0 1 0 0 \n",
"4 0 ... 0 0 1 0 \n",
".. ... ... ... ... ... ... \n",
"715 0 ... 0 0 0 0 \n",
"716 0 ... 0 0 0 0 \n",
"717 0 ... 0 0 0 0 \n",
"718 0 ... 0 0 0 0 \n",
"719 0 ... 0 0 0 0 \n",
"\n",
" miesiąc_7 miesiąc_8 miesiąc_9 miesiąc_10 miesiąc_11 miesiąc_12 \n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
".. ... ... ... ... ... ... \n",
"715 0 1 0 0 0 0 \n",
"716 0 0 1 0 0 0 \n",
"717 0 0 0 1 0 0 \n",
"718 0 0 0 0 1 0 \n",
"719 0 0 0 0 0 1 \n",
"\n",
"[720 rows x 73 columns]"
]
},
"execution_count": 334,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x_test = x_test.iloc[:-8760]\n",
"x_test"
]
},
{
"cell_type": "code",
"execution_count": 335,
"id": "1163c550",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"23/23 [==============================] - 0s 2ms/step\n"
]
}
],
"source": [
"pred= model.predict(x_test)"
]
},
{
"cell_type": "code",
"execution_count": 336,
"id": "6c24ee76",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"23/23 [==============================] - 0s 2ms/step\n"
]
}
],
"source": [
"pred= model.predict(x_test)\n",
"out = pd.DataFrame(pred)\n",
"out.to_csv('test-A/out.tsv',sep='\\t',header=False, index=False)"
]
}
],
"metadata": {
"interpreter": {
"hash": "754a2b6bedec8aae7cfc361a819067f3f72b778cb88f366be5c7fdc236f21674"
},
"kernelspec": {
"display_name": "Python 3.9.7 ('base')",
"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"
}
},
"nbformat": 4,
"nbformat_minor": 5
}