1

I am building a sarimax model to predict the number of passengers from April 2021 onwards. Currently I am using the data from 1 Jan to 31 Jan 2021 as seen below

How do i write the code so that i can predict future data from 1 Apr 2021 onwards? Thanks

#Code 1


date_forecast = "2021-3-21" #between Mar 16 - 31 (## User will key in the date)
holiday = 1

weekend = int(((pd.to_datetime(date_forecast).dayofweek)//5==1))
print('Weekend:',weekend)
print('Holiday:',holiday)

#Code 2

ridership_df2 = get_busstops_guests_hourly(ridership_df)
ridership_df2['Date'] = ridership_df2['Open Timestamp'].dt.date
ridership_df2['Date'] = pd.to_datetime(ridership_df2['Date'])
ridership_df2 = pd.merge(ridership_df2,df_holiday,how='inner',on='Date')

#Code 3

estimated_guest = pred_sarimax[date_forecast]
bus_forecast = get_busstops_guests_hourly_distribution (ridership_df2,bus_route,weekend,holiday)
print('On',date_forecast,'the Total Estimated Guest for',bus_route,':',round(estimated_guest))

#Code 4

bus_forecast = bus_forecast.reset_index()
bus_forecast['Weight'] = bus_forecast['Upper_bound'].div(bus_forecast['Upper_bound'].sum())
bus_forecast['Prediction'] = (bus_forecast['Weight']*estimated_guest).round(0)

#Code 5

bus_forecast.loc[bus_forecast ['Prediction']>50]

This will give you the output as shown in this image

#This is outputenter image description here

pot
  • 37
  • 3
  • What exactly is the question here? Do you want to know how to build an SARIMAX model with the data from the image? – Arne Decker Jan 12 '22 at 21:21

0 Answers0