# index values of months (used for given start of sets for test and training) JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 #Read and scale data = bm.read_data(FILE_NAME) #pd.concat([bm.read_data("preprocessed_471_2016.csv"), data]) data['Scaled'], sc = bm.scale_data(data) #drop the speed column which includes real speed values (scaled values will be used instead) data.drop(['Speed'], axis='columns', inplace=True) #Nerging another sensor data to main one #data_2 = bm.read_data(SECOND_FILE) #data_2['Scaled_2'], sc = bm.scale_data(data_2, sc) #data_2.drop(['Speed'], axis = 'columns', inplace = True) #data_3 = bm.read_data(THIRD_FILE) #data_3['Scaled_3'], sc = bm.scale_data(data_3, sc) #data_3.drop(['Speed'], axis = 'columns', inplace = True) #data_2 = bm.merge_two_data(data_2, data_3)
# index values of months (used for given start of sets for test and training) JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 #Read and scale data data = bm.read_data(FILE_NAME) #data = pd.concat([bm.read_data("preprocessed_471_2016.csv"), data]) data['Scaled'], sc = bm.scale_data(data) #drop the speed column which includes real speed values (scaled values will be used instead) data.drop(['Speed'], axis='columns', inplace=True) #Nerging another sensor data to main one data_2 = bm.read_data(SECOND_FILE) data_2['Scaled_2'], sc = bm.scale_data(data_2, sc) data_2.drop(['Speed'], axis='columns', inplace=True) data = bm.merge_two_data(data_2, data) #adding more prev data data_prev = data.shift(7 * 24 * 12) #data_prev_2 = data.shift(2*7*24*12)
"Avcilar": "speed_data\\Avcilar\\preprocessed_731_2017.csv", "Bogazici": "speed_data\\Bogazici\\preprocessed_442_2017.csv", "FSM": "speed_data\\FSM\\preprocessed_471_2017.csv", "Kucukcekmece": "speed_data\\Kucukcekmece\\preprocessed_735_2017.csv", "Maltepe": "speed_data\\Maltepe\\preprocessed_319_2017.csv", "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'])
# index values of months (used for given start of sets for test and training) JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 #Read and scale data data = bm.read_data(FILE_NAME) data = pd.concat([bm.read_data("preprocessed_471_2016.csv"), data]) data['Scaled'], sc = bm.scale_data(data) #drop the speed column which includes real speed values (scaled values will be used instead) data.drop(['Speed'], axis='columns', inplace=True) #Nerging another sensor data to main one #data_2 = bm.read_data("preprocessed_470.csv") #data_2['Scaled_2'], sc = bm.scale_data(data_2, sc) #data_2.drop(['Speed'], axis = 'columns', inplace = True) #data = bm.merge_two_data(data_2, data) #adding more prev data data_prev = data.shift(7*24*12) #data_prev_2 = data.shift(2*7*24*12)
# index values of months (used for given start of sets for test and training) JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 data = bm.read_data(FILE_NAME) ests = bm.read_data(SECOND_FILE) ests.drop(['Real'], axis='columns', inplace=True) data_prev = data.shift(7*24*12) data_prev.columns = ['week_before'] plot_data = pd.concat([data, data_prev,ests], axis =1) plot_data = plot_data[plot_data.index.month == JUN] plot_data = plot_data[plot_data.index.day < 10] plot_data.plot(y = ['Speed', 'Predictions']) plt.show()