Skip to content

Commit

Permalink
Removed commented tests in test_uncertainty.py. (#1032)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Stromer <noxan@users.noreply.github.com>
  • Loading branch information
Kevin-Chen0 and noxan authored Dec 3, 2022
1 parent cc19b2f commit 9f90fcc
Showing 1 changed file with 0 additions and 131 deletions.
131 changes: 0 additions & 131 deletions tests/test_uncertainty.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,134 +215,3 @@ def test_split_conformal_prediction():
fig2 = m.plot_components(forecast)
fig3 = m.plot_parameters()
plt.show()


"""
def test_uncertainty_estimation_plot():
log.info("testing: Quantile Regression Plotting")
df = pd.read_csv(PEYTON_FILE, nrows=NROWS)
# Without auto-regression enabled
m = NeuralProphet(
n_forecasts=7,
quantiles=[0.25, 0.75],
epochs=EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LR,
)
metrics_df = m.fit(df, freq="D")
future = m.make_future_dataframe(df, periods=m.n_forecasts, n_historic_predictions=10)
forecast = m.predict(future)
fig0 = m.plot(forecast)
# fig0 = m.plot_latest_forecast(forecast, include_previous_forecasts=10)
fig1 = m.plot_components(forecast)
fig2 = m.plot_parameters()
if PLOT:
plt.show()
# With auto-regression enabled
m = NeuralProphet(
n_forecasts=7,
n_lags=14,
quantiles=[0.25, 0.75],
epochs=EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LR,
)
metrics_df = m.fit(df, freq="D")
future = m.make_future_dataframe(df, periods=m.n_forecasts, n_historic_predictions=10)
forecast = m.predict(future)
m.highlight_nth_step_ahead_of_each_forecast(m.n_forecasts)
fig0 = m.plot(forecast)
fig1 = m.plot_latest_forecast(forecast, include_previous_forecasts=10)
fig2 = m.plot_latest_forecast(forecast, include_previous_forecasts=10, plot_history_data=True)
fig3 = m.plot_latest_forecast(forecast, include_previous_forecasts=10, plot_history_data=False)
fig4 = m.plot_components(forecast)
fig5 = m.plot_parameters()
if PLOT:
plt.show()
## Global Model Plot
df1 = df.copy(deep=True)
df1["ID"] = "df1"
df2 = df.copy(deep=True)
df2["ID"] = "df2"
df_global = pd.concat((df1, df2))
m = NeuralProphet(
n_forecasts=7,
n_lags=14,
quantiles=[0.25, 0.75],
epochs=EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LR,
)
metrics_df = m.fit(df_global, freq="D")
future = m.make_future_dataframe(df_global, periods=m.n_forecasts, n_historic_predictions=10)
forecast = m.predict(future)
m.highlight_nth_step_ahead_of_each_forecast(m.n_forecasts)
log.info("Plot forecast with many IDs - Raise exceptions")
with pytest.raises(Exception):
m.plot(forecast)
with pytest.raises(Exception):
m.plot_latest_forecast(forecast, include_previous_forecasts=10)
with pytest.raises(Exception):
m.plot_components(forecast)
forecast = m.predict(df_global)
with pytest.raises(Exception):
m.plot(forecast)
with pytest.raises(Exception):
m.plot_latest_forecast(forecast, include_previous_forecasts=10)
with pytest.raises(Exception):
m.plot_components(forecast)
def test_split_conformal_prediction_plot():
log.info("testing: Split Conformal Prediction Plotting")
df = pd.read_csv(PEYTON_FILE, nrows=NROWS)
# Without auto-regression enabled
m = NeuralProphet(
n_forecasts=7,
quantiles=[0.05, 0.95],
epochs=EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LR,
)
train_df, test_df = m.split_df(df, freq="MS", valid_p=0.2)
train_df, cal_df = m.split_df(train_df, freq="MS", valid_p=0.15)
metrics_df = m.fit(train_df, freq="D")
alpha = 0.1
for method in ["naive", "cqr"]: # Naive and CQR SCP methods
m.conformalize(cal_df, alpha=alpha, method=method)
future = m.make_future_dataframe(test_df, periods=m.n_forecasts, n_historic_predictions=10)
forecast = m.predict(future)
fig0 = m.plot(forecast)
# fig0 = m.plot_latest_forecast(forecast, include_previous_forecasts=10)
fig1 = m.plot_components(forecast)
fig2 = m.plot_parameters()
if PLOT:
plt.show()
# With auto-regression enabled
# TO-DO: Fix Assertion error n_train >= 1
# m = NeuralProphet(
# n_forecasts=7,
# n_lags=14,
# quantiles=[0.05, 0.95],
# epochs=EPOCHS,
# batch_size=BATCH_SIZE,
# learning_rate=LR,
# )
# train_df, test_df = m.split_df(df, freq="MS", valid_p=0.2)
# train_df, cal_df = m.split_df(train_df, freq="MS", valid_p=0.15)
# metrics_df = m.fit(train_df, freq="D")
# alpha = 0.1
# for method in ["naive", "cqr"]: # Naive and CQR SCP methods
# m.conformalize(cal_df, alpha=alpha, method=method)
# future = m.make_future_dataframe(df, periods=m.n_forecasts, n_historic_predictions=10)
# forecast = m.predict(future)
# m.highlight_nth_step_ahead_of_each_forecast(m.n_forecasts)
# fig0 = m.plot(forecast)
# fig1 = m.plot_latest_forecast(forecast, include_previous_forecasts=10)
# fig2 = m.plot_latest_forecast(forecast, include_previous_forecasts=10, plot_history_data=True)
# fig3 = m.plot_latest_forecast(forecast, include_previous_forecasts=10, plot_history_data=False)
# fig4 = m.plot_components(forecast)
# fig5 = m.plot_parameters()
# if PLOT:
# plt.show()
"""

0 comments on commit 9f90fcc

Please sign in to comment.