#data_prev = bm.merge_two_data(data_prev_2, data_prev)
#data = bm.merge_two_data(data_prev, data)

#channge missing values 0 to NaN
data.replace(0, np.nan, inplace = True)

#add one hots to data
data = bm.join_weekday_one_hot(data)
data = bm.join_daypart_one_hot(data)
#data = bm.join_minute_one_hot(data)

#Prepare the sets
features = len(data.columns)
x_features = features * TIME_STEP

reframed = bm.series_to_supervised(data, TIME_INTERVAL, TIME_DIFFERENCE, SAMPLE_FREQUENCY)

train = reframed[reframed.index.month < MAY]
test = reframed[reframed.index.month == MAY]

#removing weekends from database
#train = train[train.index.weekday < 5]
#test = test[test.index.weekday < 5]


x_train, y_train = train.values[:,:x_features],train.values[:,-1]
x_test, y_test = test.values[:,:x_features],test.values[:,-1]

#reshape the x's to 3D[sample, time_steps, features]
x_train = x_train.reshape([x_train.shape[0], int(x_train.shape[1] / features),features])
x_test = x_test.reshape([x_test.shape[0], int(x_test.shape[1] / features),features])
Beispiel #2
0
    "Sisli": "speed_data\\Sisli\\preprocessed_1745_2017.csv",
    "Sultanbeyli": "speed_data\\Sultanbeyli\\preprocessed_636_2017.csv",
    "Umraniye": "speed_data\\Umraniye\\preprocessed_619_2017.csv"
}

mapes = {}

for file_name in FILES.keys():
    time_interval = 20

    data = bm.read_data(FILES[file_name])
    data['Scaled'], sc = bm.scale_data(data)
    data.drop(['Speed'], axis='columns', inplace=True)
    data.replace(0, np.nan, inplace=True)

    reframed = bm.series_to_supervised(data, time_interval, 7 * 24 * 60, 5)
    reframed = reframed[reframed.index.month == 5]
    est = np.mean(reframed.values[:, :-1], axis=1)
    result = reframed.values[:, -1]
    mape = bm.mean_absolute_percentage_error(result, est)
    mapes[file_name] = mape

mapes_20 = pd.DataFrame.from_dict(data=mapes,
                                  orient='index',
                                  columns=['mape_20'])

mapes = {}

for file_name in FILES.keys():
    time_interval = 30