text_html_output_1.png
from sklearn.preprocessing import MinMaxScaler

import math

import numpy as np

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

submission = pd.read_csv('/kaggle/input/gdz22-datathon/submission.csv')
df = pd.read_csv('/kaggle/input/gdz22-datathon/train.csv')
trafo = pd.read_csv('/kaggle/input/gdz22-datathon/trafo.csv')
bulutluluk_orani = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Bulutluluk Oranı.csv')
bagil_nem = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Bağıl Nem.csv')
radyasyon = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Radyasyon.csv')
sicaklik = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Sıcaklık.csv')
ruzgar_yonu = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Rüzgar Yönü.csv')
yagis = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Yağış.csv')
ruzgar_hizi = pd.read_csv('/kaggle/input/gdz22-datathon/Hava Durumu/Rüzgar Hızı.csv')

df['BAŞLAMA_TARİHİ_VE_ZAMANI'] = pd.to_datetime(df['BAŞLAMA_TARİHİ_VE_ZAMANI'])

df = df.sort_values(by='BAŞLAMA_TARİHİ_VE_ZAMANI')
df

df = pd.merge(df, trafo, on='ŞEBEKE_UNSURU_KODU', how='left')

df.columns

df.groupby(['trafo_id']).sum()['KESİNTİ_SÜRESİ']

df.groupby('trafo_id').sum()['KESİNTİ_SÜRESİ'].reset_index()

a = df.groupby('trafo_id').sum()['KESİNTİ_SÜRESİ'].reset_index()
a.columns = ['trafo_id', 'KESİNTİ_SÜRESİ_YENİ']
a

df = pd.merge(df, a, on='trafo_id')

dfa = df[['Tarih', 'KESİNTİ_SÜRESİ_YENİ']].sort_values(by='Tarih')
dfa

df_new = dfa.groupby('Tarih').sum()

import math
dataset = df_new.values
training_data_len = math.ceil(len(dataset) * 0.8)
training_data_len

from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler(feature_range=(0, 1))
scaled_data = sc.fit_transform(dataset)

train_data = scaled_data[0:training_data_len, :]
x_train = []
y_train = []
num = 80
for i in range(num, len(train_data)):
    x_train.append(train_data[i - num:i, 0])
    y_train.append(train_data[i, 0])

x_train, y_train = (np.array(x_train), np.array(y_train))
x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1))
x_train.shape