Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed commented tests in test_uncertainty.py. #1032

Merged
merged 2 commits into from
Dec 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
"""