{ "cells": [ { "cell_type": "code", "execution_count": 295, "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": 296, "id": "70e3b6e3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8760" ] }, "execution_count": 296, "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": 297, "id": "44f404d6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "720" ] }, "execution_count": 297, "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": 298, "id": "c760402a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 298, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.concat([df,df_test])\n", "len(df)" ] }, { "cell_type": "code", "execution_count": 299, "id": "06f39e15", "metadata": {}, "outputs": [], "source": [ "df = df.drop(['nazwa_stacji','typ_zbioru'], axis=1)" ] }, { "cell_type": "code", "execution_count": 300, "id": "91c047f6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
id_stacji_249180010id_stacji_249190560id_stacji_249200370id_stacji_249200490id_stacji_249220150id_stacji_249220180id_stacji_250190160id_stacji_250190390id_stacji_250210130id_stacji_251170090...miesiąc_3miesiąc_4miesiąc_5miesiąc_6miesiąc_7miesiąc_8miesiąc_9miesiąc_10miesiąc_11miesiąc_12
01000000000...0000000000
11000000000...0000000000
21000000000...1000000000
31000000000...0100000000
41000000000...0010000000
..................................................................
7150000000000...0000010000
7160000000000...0000001000
7170000000000...0000000100
7180000000000...0000000010
7190000000000...0000000001
\n", "

9480 rows × 73 columns

\n", "
" ], "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": 300, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = pd.get_dummies(df,columns = ['id_stacji','rok','miesiąc'])\n", "x" ] }, { "cell_type": "code", "execution_count": 301, "id": "037f1315", "metadata": {}, "outputs": [], "source": [ "x = x.iloc[:-720]" ] }, { "cell_type": "code", "execution_count": 302, "id": "e03bae07", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
id_stacji_249180010id_stacji_249190560id_stacji_249200370id_stacji_249200490id_stacji_249220150id_stacji_249220180id_stacji_250190160id_stacji_250190390id_stacji_250210130id_stacji_251170090...miesiąc_3miesiąc_4miesiąc_5miesiąc_6miesiąc_7miesiąc_8miesiąc_9miesiąc_10miesiąc_11miesiąc_12
01000000000...0000000000
11000000000...0000000000
21000000000...1000000000
31000000000...0100000000
41000000000...0010000000
..................................................................
87550000000000...0000010000
87560000000000...0000001000
87570000000000...0000000100
87580000000000...0000000010
87590000000000...0000000001
\n", "

8760 rows × 73 columns

\n", "
" ], "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": 302, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x" ] }, { "cell_type": "code", "execution_count": 303, "id": "ede98181", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rainfall
019.4
143.2
272.2
325.3
489.3
......
8755114.9
8756101.2
875720.4
875893.2
875946.9
\n", "

8760 rows × 1 columns

\n", "
" ], "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": 303, "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": 304, "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": 305, "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": 306, "id": "c1036c04", "metadata": {}, "outputs": [], "source": [ "y = np.asarray(y).astype('float32')" ] }, { "cell_type": "code", "execution_count": 307, "id": "cec44474", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(None, 73) \n", "(None, 1) \n", "dense_95 (None, 73) float32\n", "dense_96 (None, 1024) float32\n", "dense_97 (None, 512) float32\n", "dense_98 (None, 256) float32\n", "dense_99 (None, 128) float32\n", "dense_100 (None, 64) float32\n", "dense_101 (None, 32) float32\n", "dense_102 (None, 16) float32\n" ] }, { "data": { "text/plain": [ "[None, None, None, None, None, None, None, None]" ] }, "execution_count": 307, "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": 308, "id": "eb9cb318", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch 1/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 1216.5399 - mean_squared_error: 1216.5399\n", "Epoch 2/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 794.1711 - mean_squared_error: 794.1711\n", "Epoch 3/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 580.7461 - mean_squared_error: 580.7461\n", "Epoch 4/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 484.1317 - mean_squared_error: 484.1317\n", "Epoch 5/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 441.7448 - mean_squared_error: 441.7448\n", "Epoch 6/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 392.2047 - mean_squared_error: 392.2047\n", "Epoch 7/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 361.4105 - mean_squared_error: 361.4105\n", "Epoch 8/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 312.9633 - mean_squared_error: 312.9633\n", "Epoch 9/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 275.2529 - mean_squared_error: 275.2529\n", "Epoch 10/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 246.7625 - mean_squared_error: 246.7625\n", "Epoch 11/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 195.6685 - mean_squared_error: 195.6685\n", "Epoch 12/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 168.8491 - mean_squared_error: 168.8491\n", "Epoch 13/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 150.1201 - mean_squared_error: 150.1201\n", "Epoch 14/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 122.6171 - mean_squared_error: 122.6171\n", "Epoch 15/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 100.8923 - mean_squared_error: 100.8923\n", "Epoch 16/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 87.8484 - mean_squared_error: 87.8484\n", "Epoch 17/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 77.6876 - mean_squared_error: 77.6876\n", "Epoch 18/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 63.2032 - mean_squared_error: 63.2032\n", "Epoch 19/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 57.2543 - mean_squared_error: 57.2543\n", "Epoch 20/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 45.0924 - mean_squared_error: 45.0924\n", "Epoch 21/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 49.1593 - mean_squared_error: 49.1593\n", "Epoch 22/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 58.2306 - mean_squared_error: 58.2306\n", "Epoch 23/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 48.0242 - mean_squared_error: 48.0242\n", "Epoch 24/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 38.6356 - mean_squared_error: 38.6356\n", "Epoch 25/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 30.9926 - mean_squared_error: 30.9926\n", "Epoch 26/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 29.7819 - mean_squared_error: 29.7819\n", "Epoch 27/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 32.5139 - mean_squared_error: 32.5139\n", "Epoch 28/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 40.1129 - mean_squared_error: 40.1129\n", "Epoch 29/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 51.6793 - mean_squared_error: 51.6793\n", "Epoch 30/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 37.1284 - mean_squared_error: 37.1284\n", "Epoch 31/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 30.2074 - mean_squared_error: 30.2074\n", "Epoch 32/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 27.1982 - mean_squared_error: 27.1982\n", "Epoch 33/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 26.5477 - mean_squared_error: 26.5477\n", "Epoch 34/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 25.7544 - mean_squared_error: 25.7544\n", "Epoch 35/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 24.1754 - mean_squared_error: 24.1754\n", "Epoch 36/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 27.5213 - mean_squared_error: 27.5213\n", "Epoch 37/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 30.3435 - mean_squared_error: 30.3435\n", "Epoch 38/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 32.7374 - mean_squared_error: 32.7374\n", "Epoch 39/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 29.2545 - mean_squared_error: 29.2545\n", "Epoch 40/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 28.4834 - mean_squared_error: 28.4834\n", "Epoch 41/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 22.9177 - mean_squared_error: 22.9177\n", "Epoch 42/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 21.6796 - mean_squared_error: 21.6796\n", "Epoch 43/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 20.2429 - mean_squared_error: 20.2429\n", "Epoch 44/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 21.2112 - mean_squared_error: 21.2112\n", "Epoch 45/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 25.0341 - mean_squared_error: 25.0341\n", "Epoch 46/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 22.3963 - mean_squared_error: 22.3963\n", "Epoch 47/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 23.1122 - mean_squared_error: 23.1122\n", "Epoch 48/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 28.0343 - mean_squared_error: 28.0343\n", "Epoch 49/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 22.2908 - mean_squared_error: 22.2908\n", "Epoch 50/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 21.7871 - mean_squared_error: 21.7871\n", "Epoch 51/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 19.8841 - mean_squared_error: 19.8841\n", "Epoch 52/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 20.5390 - mean_squared_error: 20.5390\n", "Epoch 53/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 22.3869 - mean_squared_error: 22.3869\n", "Epoch 54/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 20.6540 - mean_squared_error: 20.6540\n", "Epoch 55/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 18.3056 - mean_squared_error: 18.3056\n", "Epoch 56/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 22.7574 - mean_squared_error: 22.7574\n", "Epoch 57/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 20.1425 - mean_squared_error: 20.1425\n", "Epoch 58/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 17.5521 - mean_squared_error: 17.5521\n", "Epoch 59/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 18.2735 - mean_squared_error: 18.2735\n", "Epoch 60/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 17.6372 - mean_squared_error: 17.6372\n", "Epoch 61/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 15.2790 - mean_squared_error: 15.2790\n", "Epoch 62/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 12.9527 - mean_squared_error: 12.9527\n", "Epoch 63/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 13.2732 - mean_squared_error: 13.2732\n", "Epoch 64/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 18.0740 - mean_squared_error: 18.0740\n", "Epoch 65/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 23.5823 - mean_squared_error: 23.5823\n", "Epoch 66/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 22.4731 - mean_squared_error: 22.4731\n", "Epoch 67/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 17.0889 - mean_squared_error: 17.0889\n", "Epoch 68/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 13.5507 - mean_squared_error: 13.5507\n", "Epoch 69/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 14.6270 - mean_squared_error: 14.6270\n", "Epoch 70/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 15.7420 - mean_squared_error: 15.7420\n", "Epoch 71/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 15.6920 - mean_squared_error: 15.6920\n", "Epoch 72/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 17.8469 - mean_squared_error: 17.8469\n", "Epoch 73/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 20.0690 - mean_squared_error: 20.0690\n", "Epoch 74/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 16.4538 - mean_squared_error: 16.4538\n", "Epoch 75/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 13.7226 - mean_squared_error: 13.7226\n", "Epoch 76/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 11.6082 - mean_squared_error: 11.6082\n", "Epoch 77/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 11.4206 - mean_squared_error: 11.4206\n", "Epoch 78/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 12.9487 - mean_squared_error: 12.9487\n", "Epoch 79/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 14.9138 - mean_squared_error: 14.9138\n", "Epoch 80/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 16.7601 - mean_squared_error: 16.7601\n", "Epoch 81/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 16.3490 - mean_squared_error: 16.3490\n", "Epoch 82/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 12.4280 - mean_squared_error: 12.4280\n", "Epoch 83/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 9.2046 - mean_squared_error: 9.2046\n", "Epoch 84/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 8.5721 - mean_squared_error: 8.5721\n", "Epoch 85/100\n", "274/274 [==============================] - 2s 7ms/step - loss: 9.8912 - mean_squared_error: 9.8912\n", "Epoch 86/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.4523 - mean_squared_error: 10.4523\n", "Epoch 87/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 19.6175 - mean_squared_error: 19.6175\n", "Epoch 88/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 16.5808 - mean_squared_error: 16.5808\n", "Epoch 89/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 15.8564 - mean_squared_error: 15.8564\n", "Epoch 90/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 12.2800 - mean_squared_error: 12.2800\n", "Epoch 91/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.0090 - mean_squared_error: 10.0090\n", "Epoch 92/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 9.4647 - mean_squared_error: 9.4647\n", "Epoch 93/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.7999 - mean_squared_error: 10.7999\n", "Epoch 94/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.2449 - mean_squared_error: 10.2449\n", "Epoch 95/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.0525 - mean_squared_error: 10.0525\n", "Epoch 96/100\n", "274/274 [==============================] - 2s 5ms/step - loss: 11.3375 - mean_squared_error: 11.3375\n", "Epoch 97/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 11.6955 - mean_squared_error: 11.6955\n", "Epoch 98/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 11.2546 - mean_squared_error: 11.2546\n", "Epoch 99/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 10.2126 - mean_squared_error: 10.2126\n", "Epoch 100/100\n", "274/274 [==============================] - 2s 6ms/step - loss: 8.5690 - mean_squared_error: 8.5690\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 308, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.compile(loss= \"mean_squared_error\" , optimizer=\"adam\", metrics=[\"mean_squared_error\"])\n", "model.fit(x, y, epochs=100)" ] }, { "cell_type": "code", "execution_count": 309, "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": 310, "id": "a3b6fff0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 310, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x_test = pd.concat([x_test,df_train])\n", "len(x_test)" ] }, { "cell_type": "code", "execution_count": 311, "id": "cdf89362", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 311, "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": 312, "id": "fe00b876", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
id_stacji_249180010id_stacji_249190560id_stacji_249200370id_stacji_249200490id_stacji_249220150id_stacji_249220180id_stacji_250190160id_stacji_250190390id_stacji_250210130id_stacji_251170090...miesiąc_3miesiąc_4miesiąc_5miesiąc_6miesiąc_7miesiąc_8miesiąc_9miesiąc_10miesiąc_11miesiąc_12
00010000000...0000000000
10010000000...0000000000
20010000000...1000000000
30010000000...0100000000
40010000000...0010000000
..................................................................
87550000000000...0000010000
87560000000000...0000001000
87570000000000...0000000100
87580000000000...0000000010
87590000000000...0000000001
\n", "

9480 rows × 73 columns

\n", "
" ], "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": 312, "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": 313, "id": "657a7976", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
id_stacji_249180010id_stacji_249190560id_stacji_249200370id_stacji_249200490id_stacji_249220150id_stacji_249220180id_stacji_250190160id_stacji_250190390id_stacji_250210130id_stacji_251170090...miesiąc_3miesiąc_4miesiąc_5miesiąc_6miesiąc_7miesiąc_8miesiąc_9miesiąc_10miesiąc_11miesiąc_12
00010000000...0000000000
10010000000...0000000000
20010000000...1000000000
30010000000...0100000000
40010000000...0010000000
..................................................................
7150000000000...0000010000
7160000000000...0000001000
7170000000000...0000000100
7180000000000...0000000010
7190000000000...0000000001
\n", "

720 rows × 73 columns

\n", "
" ], "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": 313, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x_test = x_test.iloc[:-8760]\n", "x_test" ] }, { "cell_type": "code", "execution_count": 314, "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": 315, "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 }