{ "cells": [ { "cell_type": "code", "execution_count": 1, "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": 2, "id": "70e3b6e3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8760" ] }, "execution_count": 2, "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": 3, "id": "44f404d6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "720" ] }, "execution_count": 3, "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": 4, "id": "c760402a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.concat([df,df_test])\n", "len(df)" ] }, { "cell_type": "code", "execution_count": 5, "id": "06f39e15", "metadata": {}, "outputs": [], "source": [ "df = df.drop(['nazwa_stacji','typ_zbioru'], axis=1)" ] }, { "cell_type": "code", "execution_count": 6, "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": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = pd.get_dummies(df,columns = ['id_stacji','rok','miesiąc'])\n", "x" ] }, { "cell_type": "code", "execution_count": 7, "id": "037f1315", "metadata": {}, "outputs": [], "source": [ "x = x.iloc[:-720]" ] }, { "cell_type": "code", "execution_count": 8, "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": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x" ] }, { "cell_type": "code", "execution_count": 9, "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": 9, "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": 10, "id": "9a950571", "metadata": {}, "outputs": [], "source": [ "# Define model\n", "model = Sequential()\n", "model.add(Dense(16, input_dim=73, activation= \"relu\"))\n", "model.add(Dense(32, 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": 11, "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": 12, "id": "c1036c04", "metadata": {}, "outputs": [], "source": [ "y = np.asarray(y).astype('float32')" ] }, { "cell_type": "code", "execution_count": 13, "id": "cec44474", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(None, 73) \n", "(None, 1) \n", "dense (None, 73) float32\n", "dense_1 (None, 16) float32\n", "dense_2 (None, 32) float32\n", "dense_3 (None, 64) float32\n", "dense_4 (None, 32) float32\n", "dense_5 (None, 16) float32\n" ] }, { "data": { "text/plain": [ "[None, None, None, None, None, None]" ] }, "execution_count": 13, "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": 14, "id": "eb9cb318", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch 1/100\n", "274/274 [==============================] - 1s 1ms/step - loss: 1904.0205 - mean_squared_error: 1904.0205\n", "Epoch 2/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 977.0018 - mean_squared_error: 977.0018\n", "Epoch 3/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 930.0125 - mean_squared_error: 930.0125\n", "Epoch 4/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 902.6553 - mean_squared_error: 902.6553\n", "Epoch 5/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 863.2485 - mean_squared_error: 863.2485\n", "Epoch 6/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 811.9504 - mean_squared_error: 811.9504\n", "Epoch 7/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 770.9260 - mean_squared_error: 770.9260\n", "Epoch 8/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 724.6091 - mean_squared_error: 724.6091\n", "Epoch 9/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 692.6209 - mean_squared_error: 692.6209\n", "Epoch 10/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 659.7095 - mean_squared_error: 659.7095\n", "Epoch 11/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 625.7371 - mean_squared_error: 625.7371\n", "Epoch 12/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 602.4116 - mean_squared_error: 602.4116\n", "Epoch 13/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 577.0346 - mean_squared_error: 577.0346\n", "Epoch 14/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 552.9323 - mean_squared_error: 552.9323\n", "Epoch 15/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 529.7372 - mean_squared_error: 529.7372\n", "Epoch 16/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 515.2844 - mean_squared_error: 515.2844\n", "Epoch 17/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 501.1700 - mean_squared_error: 501.1700\n", "Epoch 18/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 489.9219 - mean_squared_error: 489.9219\n", "Epoch 19/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 484.0696 - mean_squared_error: 484.0696\n", "Epoch 20/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 470.3400 - mean_squared_error: 470.3400\n", "Epoch 21/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 459.1194 - mean_squared_error: 459.1194\n", "Epoch 22/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 455.5881 - mean_squared_error: 455.5881\n", "Epoch 23/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 446.4247 - mean_squared_error: 446.4247\n", "Epoch 24/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 440.6260 - mean_squared_error: 440.6260\n", "Epoch 25/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 434.9443 - mean_squared_error: 434.9443\n", "Epoch 26/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 429.9223 - mean_squared_error: 429.9223\n", "Epoch 27/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 424.0781 - mean_squared_error: 424.0781\n", "Epoch 28/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 420.9750 - mean_squared_error: 420.9750\n", "Epoch 29/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 416.1357 - mean_squared_error: 416.1357\n", "Epoch 30/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 409.1339 - mean_squared_error: 409.1339\n", "Epoch 31/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 404.7644 - mean_squared_error: 404.7644\n", "Epoch 32/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 403.4354 - mean_squared_error: 403.4354\n", "Epoch 33/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 398.6223 - mean_squared_error: 398.6223\n", "Epoch 34/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 391.9509 - mean_squared_error: 391.9509\n", "Epoch 35/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 391.3186 - mean_squared_error: 391.3186\n", "Epoch 36/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 388.1175 - mean_squared_error: 388.1175\n", "Epoch 37/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 385.9730 - mean_squared_error: 385.9730\n", "Epoch 38/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 382.0468 - mean_squared_error: 382.0468\n", "Epoch 39/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 376.9197 - mean_squared_error: 376.9197\n", "Epoch 40/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 378.0434 - mean_squared_error: 378.0434\n", "Epoch 41/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 372.7451 - mean_squared_error: 372.7451\n", "Epoch 42/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 368.2292 - mean_squared_error: 368.2292\n", "Epoch 43/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 369.8233 - mean_squared_error: 369.8233\n", "Epoch 44/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 365.3695 - mean_squared_error: 365.3695\n", "Epoch 45/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 363.1947 - mean_squared_error: 363.1947\n", "Epoch 46/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 358.6509 - mean_squared_error: 358.6509\n", "Epoch 47/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 363.4928 - mean_squared_error: 363.4928\n", "Epoch 48/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 359.9735 - mean_squared_error: 359.9735\n", "Epoch 49/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 353.2738 - mean_squared_error: 353.2738\n", "Epoch 50/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 350.3524 - mean_squared_error: 350.3524\n", "Epoch 51/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 349.1338 - mean_squared_error: 349.1338\n", "Epoch 52/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 351.0474 - mean_squared_error: 351.0474\n", "Epoch 53/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 341.8802 - mean_squared_error: 341.8802\n", "Epoch 54/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 341.5201 - mean_squared_error: 341.5201\n", "Epoch 55/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 339.8927 - mean_squared_error: 339.8927\n", "Epoch 56/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 337.5977 - mean_squared_error: 337.5977\n", "Epoch 57/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 341.8250 - mean_squared_error: 341.8250\n", "Epoch 58/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 334.7910 - mean_squared_error: 334.7910\n", "Epoch 59/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 333.3398 - mean_squared_error: 333.3398\n", "Epoch 60/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 330.1293 - mean_squared_error: 330.1293\n", "Epoch 61/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 331.5085 - mean_squared_error: 331.5085\n", "Epoch 62/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 327.4076 - mean_squared_error: 327.4076\n", "Epoch 63/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 328.1978 - mean_squared_error: 328.1978\n", "Epoch 64/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 322.5495 - mean_squared_error: 322.5495\n", "Epoch 65/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 324.4060 - mean_squared_error: 324.4060\n", "Epoch 66/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 319.2129 - mean_squared_error: 319.2129\n", "Epoch 67/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 320.8315 - mean_squared_error: 320.8315\n", "Epoch 68/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 315.9987 - mean_squared_error: 315.9987\n", "Epoch 69/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 314.6494 - mean_squared_error: 314.6494\n", "Epoch 70/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 310.7572 - mean_squared_error: 310.7572\n", "Epoch 71/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 310.8293 - mean_squared_error: 310.8293\n", "Epoch 72/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 310.2863 - mean_squared_error: 310.2863\n", "Epoch 73/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 309.2907 - mean_squared_error: 309.2907\n", "Epoch 74/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 306.9155 - mean_squared_error: 306.9155\n", "Epoch 75/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 304.8138 - mean_squared_error: 304.8138\n", "Epoch 76/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 303.4693 - mean_squared_error: 303.4693\n", "Epoch 77/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 302.1253 - mean_squared_error: 302.1253\n", "Epoch 78/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 300.5882 - mean_squared_error: 300.5882\n", "Epoch 79/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 300.8849 - mean_squared_error: 300.8849\n", "Epoch 80/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 297.9424 - mean_squared_error: 297.9424\n", "Epoch 81/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 296.6845 - mean_squared_error: 296.6845\n", "Epoch 82/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 301.2429 - mean_squared_error: 301.2429\n", "Epoch 83/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 294.7325 - mean_squared_error: 294.7325\n", "Epoch 84/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 293.9087 - mean_squared_error: 293.9087\n", "Epoch 85/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 294.8573 - mean_squared_error: 294.8573\n", "Epoch 86/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 291.5350 - mean_squared_error: 291.5350\n", "Epoch 87/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 288.5298 - mean_squared_error: 288.5298\n", "Epoch 88/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 290.0951 - mean_squared_error: 290.0951\n", "Epoch 89/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 286.3828 - mean_squared_error: 286.3828\n", "Epoch 90/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 282.4638 - mean_squared_error: 282.4638\n", "Epoch 91/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 290.5275 - mean_squared_error: 290.5275\n", "Epoch 92/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 282.0305 - mean_squared_error: 282.0305\n", "Epoch 93/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 281.5406 - mean_squared_error: 281.5406\n", "Epoch 94/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 287.6223 - mean_squared_error: 287.6223\n", "Epoch 95/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 277.7972 - mean_squared_error: 277.7972\n", "Epoch 96/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 279.9403 - mean_squared_error: 279.9403\n", "Epoch 97/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 275.0088 - mean_squared_error: 275.0088\n", "Epoch 98/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 276.8479 - mean_squared_error: 276.8479\n", "Epoch 99/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 275.8300 - mean_squared_error: 275.8300\n", "Epoch 100/100\n", "274/274 [==============================] - 0s 1ms/step - loss: 274.4589 - mean_squared_error: 274.4589\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 14, "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": 15, "id": "b01ccebe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "17.28555466278129" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import math\n", "math.sqrt(298.7904)" ] }, { "cell_type": "code", "execution_count": 16, "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('dev-0/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": 17, "id": "a3b6fff0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x_test = pd.concat([x_test,df_train])\n", "len(x_test)" ] }, { "cell_type": "code", "execution_count": 18, "id": "cdf89362", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9480" ] }, "execution_count": 18, "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": 19, "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": 19, "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": 20, "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": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x_test = x_test.iloc[:-8760]\n", "x_test" ] }, { "cell_type": "code", "execution_count": 21, "id": "1163c550", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "23/23 [==============================] - 0s 909us/step\n" ] } ], "source": [ "pred= model.predict(x_test)" ] }, { "cell_type": "code", "execution_count": 22, "id": "6c24ee76", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "23/23 [==============================] - 0s 955us/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 }