text_plain_output_1.png
from sklearn.preprocessing import MinMaxScaler

import numpy as np

import pandas

from sklearn.preprocessing import MinMaxScaler
def scale3DArray(arr: np.ndarray, scaler: any=MinMaxScaler(feature_range=(-1, 1))) -> np.ndarray:
    scaledArr = np.reshape(arr, (arr.shape[0], arr.shape[1] * arr.shape[2]))
    scaledArr = scaler.fit_transform(scaledArr)
    scaledArr = np.reshape(scaledArr, tuple(arr.shape))
    return scaledArr
def scale3DArrayReturningScaler(arr: np.ndarray, scaler: any=MinMaxScaler(feature_range=(-1, 1))):
    scaledArr = np.reshape(arr, (arr.shape[0], arr.shape[1] * arr.shape[2]))
    scaledArr = scaler.fit_transform(scaledArr)
    scaledArr = np.reshape(scaledArr, tuple(arr.shape))
    return (scaledArr, scaler)

data = pandas.read_csv('../input/nyc-taxi-traffic/dataset.csv')
data = list(data['value'])[:10200]

data_train = data[:int(len(data) * 0.8)]
data_test = data[int(len(data) * 0.8):]
O_data_test = data_test

minmaxSc = MinMaxScaler()
data_train = np.array(data_train)
print(data_train.shape)
data_train = np.reshape(data_train, (int(data_train.shape[0] / 120), 120))
print(data_train.shape)
data_train = minmaxSc.fit_transform(data_train)
print(data_train.shape)
train, validate = np.array_split(data_train, [72], 1)
print(train.shape)
print(validate.shape)
train = np.reshape(train, (train.shape[0], train.shape[1], 1))
validate = np.reshape(validate, (validate.shape[0], validate.shape[1], 1))
print(train.shape)
print(validate.shape)