SARIMA
SARIMA
SARIMA
February 5, 2024
'jul': 'Jul', 'ago': 'Aug', 'sep': 'Sep', 'oct': 'Oct', 'nov': 'Nov', 'dic':
↪ 'Dec'
}
# Traducir los meses y convertir la columna a tipo datetime
1
data['Month'] = data['Month'].apply(lambda x: x.replace(x[:3],␣
↪spanish_to_english[x[:3]]))
projected_df['Month_Year'] = projected_df['Month_Year'].apply(lambda x: x.
↪replace(x[:3], spanish_to_english[x[:3]]))
[562]: data.sort_index(inplace=True)
data.head(20)
C:\Users\sk8ta\anaconda3\Lib\site-
packages\statsmodels\tsa\statespace\sarimax.py:866: UserWarning: Too few
2
observations to estimate starting parameters for ARMA and trend. All parameters
except for variances will be set to zeros.
warn('Too few observations to estimate starting parameters%s.'
C:\Users\sk8ta\anaconda3\Lib\site-
packages\statsmodels\tsa\statespace\sarimax.py:866: UserWarning: Too few
observations to estimate starting parameters for seasonal ARMA. All parameters
except for variances will be set to zeros.
warn('Too few observations to estimate starting parameters%s.'
prediction_mean = sarima_prediction.predicted_mean
prediction_conf_int = sarima_prediction.conf_int()
3
[568]: # Mostrar las predicciones
prediction_mean, prediction_conf_int
predictions_table
Upper Hours_per_Night
0 0.085197
4
1 0.104551
2 0.104201
3 0.106951
4 0.114637
5 0.114714
6 0.140561
7 0.099458
8 0.093288
9 0.123107
10 0.137803
11 0.140791
12 0.133449
13 0.153696
14 0.154282
15 0.158036
16 0.166665
17 0.167659
18 0.194386
19 0.154133
20 0.148786
21 0.179403
22 0.194873
23 0.198619
24 0.189969
result_df['Total_Hours_Mean'] = result_df['Projected_Guest_Nights'] *␣
↪result_df['Prediction Mean']
5
result_df['Total_Hours_Upper'] = result_df['Projected_Guest_Nights'] *␣
↪result_df['Upper Hours_per_Night']
result_df["Courts_Needed_Lower"] = result_df["Total_Hours_Lower"] /␣
↪result_df["Total_Hours_Available"]
result_df["Courts_Needed_Mean"] = result_df["Total_Hours_Mean"] /␣
↪result_df["Total_Hours_Available"]
result_df["Courts_Needed_Upper"] = result_df["Total_Hours_Upper"] /␣
↪result_df["Total_Hours_Available"]
[571]: result_df
6
0 0.049640 2975.921010 13.226316
1 0.059748 5713.091665 25.391519
2 0.069111 5797.529697 19.991482
3 0.078467 10255.300393 35.363105
4 0.064804 5603.932765 17.567187
5 0.073164 9446.234662 29.612021
6 0.066057 2279.901109 8.940789
7 0.073439 3908.299256 15.326664
8 0.071510 2590.151412 10.157457
9 0.077937 4301.891580 16.870163
10 0.069804 1897.275596 7.440296
11 0.075319 2923.808792 11.465917
12 0.093795 1736.055230 6.808060
13 0.098429 2424.001082 9.505887
14 0.050973 830.497506 3.707578
15 0.054756 1189.136496 5.308645
16 0.043100 1307.224993 4.507672
17 0.046060 1708.057218 5.889852
18 0.071324 4118.341661 16.947908
19 0.073486 5407.130969 22.251568
20 0.084441 5612.096229 22.270223
21 0.085827 7189.956850 28.531575
22 0.085897 4637.741404 18.403736
7
22 0.113344 6119.673238 24.284418