FHV_BUS_Trips




Pay Notebook Creator: Ning Wei0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0
In [12]:
#CrossCompute
vehicle_table_path = 'monthly_FHV_count.csv'
target_folder = '/tmp'
In [13]:
import pandas as pd
vehicle_table = pd.read_csv(vehicle_table_path)
In [14]:
vehicle_table[:2]
Out[14]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
Month Number For Hire Vehicle Count
0 1 200
1 2 300
In [15]:
len(vehicle_table)
Out[15]:
12
In [16]:
vehicle_table['Predicted Bus Ride Count'] = [23,34,34,23,20,45,34,56,55,67,88,12]
vehicle_table['Actual Bus Ride Count'] = [25,54,74,83,28,49,34,56,57,69,68,72]
In [17]:
# Save table
target_path = target_folder + '/a.csv'
vehicle_table.to_csv(target_path, index=False)
print('a_table_path = %s' % target_path)
a_table_path = /tmp/a.csv
In [18]:
# Save plot
%matplotlib inline
target_path = target_folder + '/b.png'
plot_table = vehicle_table.copy()
plot_table = plot_table.set_index('Month Number')
axes = plot_table.plot(kind='line')
figure = axes.get_figure()
figure.savefig(target_path)
print(f'b_image_path = {target_path}')
b_image_path = /tmp/b.png
In [23]:
# Save number
error_table = vehicle_table.copy()
error_table['Absolute Error'] = (error_table[
'Predicted Bus Ride Count'
] - error_table[
'Actual Bus Ride Count'
]).abs()
In [24]:
error_table
Out[24]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
Month Number For Hire Vehicle Count Predicted Bus Ride Count Actual Bus Ride Count Absolute Error
0 1 200 23 25 2
1 2 300 34 54 20
2 3 230 34 74 40
3 4 330 23 83 60
4 5 540 20 28 8
5 6 400 45 49 4
6 7 230 34 34 0
7 8 543 56 56 0
8 9 340 55 57 2
9 10 230 67 69 2
10 11 450 88 68 20
11 12 200 12 72 60
In [25]:
print('mean_absolute_error = %s' % error_table['Absolute Error'].mean())
mean_absolute_error = 18.166666666666668
In [ ]: