text_plain_output_1.png image_output_1.png
from sklearn.preprocessing import MinMaxScaler

import numpy as np

import pandas as pd

df = pd.read_csv('/kaggle/input/international-airline-passengers/international-airline-passengers.csv', index_col='Month')

columns_to_keep = ['Passengers']
df = df[columns_to_keep]
df['Passengers'] = df['Passengers'].apply(lambda x: x * 1000)
df.index.names = ['Month']
df.sort_index(inplace=True)

df.isnull().sum()

null_columns = df.columns[df.isnull().any()]
df[null_columns].isnull().sum()

df.dropna(inplace=True)

df.isnull().sum()

dataset = df.astype('float32')

scaler = MinMaxScaler(feature_range=(0, 1))
scaled = scaler.fit_transform(dataset)

def create_dataset(dataset, look_back=1):
    dataX, dataY = ([], [])
    for i in range(len(dataset) - look_back - 1):
        a = dataset[i:i + look_back, 0]
        dataset[i + look_back, 0]
        dataX.append(a)
        dataY.append(dataset[i + look_back, 0])
    return (np.array(dataX), np.array(dataY))

look_back = 1
X_train, y_train = create_dataset(train, look_back)
X_test, y_test = create_dataset(test, look_back)