Skip to content

Instantly share code, notes, and snippets.

@gonzalezgouveia
Last active November 26, 2018 15:45
Show Gist options
  • Save gonzalezgouveia/d9076af694c54a2bf7384bcc7b9fc0e7 to your computer and use it in GitHub Desktop.
Save gonzalezgouveia/d9076af694c54a2bf7384bcc7b9fc0e7 to your computer and use it in GitHub Desktop.
ecobici forecast
# tomar de datos originales dias 29-oct, 30-oct, y 31-oct
df_29_31 = df_mon_to_fri.loc['2018-10-29':'2018-10-31']
df_29_31.plot()
# agregar bandas de confianza
pred_1_2_conf = results.get_forecast(steps=24*2).conf_int()
pred_1_2_conf.index = pd.date_range(start='11/1/2018', end='11/3/2018', freq='H')[:-1]
x = pd.date_range(start='11/1/2018', end='11/3/2018', freq='H')[:-1]
y1 = pred_1_2_conf['lower Bici']
y2 = pred_1_2_conf['upper Bici']
plt.fill_between(x, y1, y2, alpha=0.6)
# predecir para 1-nov y 2-nov
pred_1_2 = results.get_forecast(steps=24*2).predicted_mean
pred_1_2.index = pd.date_range(start='11/1/2018', end='11/3/2018', freq='H')[:-1]
pred_1_2.plot()
# formato de la grafica final
plt.title('Pronóstico de viajes')
plt.ylabel('Cantidad de viajes')
plt.xlabel('Semana lun-29-oct al vie-02-nov')
plt.legend(('Datos originales octubre', 'Pronóstico noviembre'),
loc='lower left')
plt.savefig('pronostico.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment