Esempio n. 1
0
 def test_score(self, jhu_data, population_data, country):
     snl = Scenario(jhu_data, population_data, country, tau=360)
     snl.trend(show_figure=False)
     snl.estimate(SIRF, timeout=10)
     metrics_list = ["MAE", "MSE", "MSLE", "RMSE", "RMSLE"]
     for metrics in metrics_list:
         score = snl.score(metrics=metrics)
         assert isinstance(score, float)
     # Selected phases
     df = snl.summary()
     all_phases = df.index.tolist()
     sel_score = snl.score(phases=all_phases[-2:])
     # Selected past days (when the begging date is a start date)
     beginning_date = df.loc[df.index[-2], Term.START]
     past_days = Term.steps(beginning_date, snl.last_date, tau=1440)
     assert snl.score(past_days=past_days) == sel_score
     # Selected past days
     snl.score(past_days=60)
Esempio n. 2
0
 def test_score(self, jhu_data, population_data, country):
     snl = Scenario(jhu_data, population_data, country, tau=360)
     snl.trend(show_figure=False)
     snl.estimate(SIRF, timeout=1, timeout_iteration=1)
     assert isinstance(snl.score(metrics="RMSLE"), float)
     # Selected phases
     df = snl.summary()
     all_phases = df.index.tolist()
     sel_score = snl.score(phases=all_phases[-2:])
     # Selected past days (when the begging date is a start date)
     beginning_date = df.loc[df.index[-2], Term.START]
     past_days = Term.steps(beginning_date, snl.last_date, tau=1440)
     assert snl.score(past_days=past_days) == sel_score
     # Selected past days
     snl.score(past_days=60)
     with pytest.raises(ValueError):
         snl.score(phases=["1st"], past_days=60)
Esempio n. 3
0
 def test_score_error(self, jhu_data, population_data, country):
     snl = Scenario(jhu_data, population_data, country)
     with pytest.raises(ValueError):
         snl.score()
     snl.trend(show_figure=False)
     with pytest.raises(NameError):
         snl.score()
     all_phases = snl.summary().index.tolist()
     snl.disable(phases=all_phases[:-2])
     snl.estimate(SIRF, timeout=10)
     with pytest.raises(TypeError):
         snl.score(phases="0th")
     with pytest.raises(KeyError):
         snl.score(phases=["100th"])
     with pytest.raises(TypeError):
         snl.score(variables="Infected")
     with pytest.raises(KeyError):
         snl.score(variables=["Susceptible"])
     with pytest.raises(ValueError):
         snl.score(metrics="Subjective evaluation")
     with pytest.raises(ValueError):
         snl.score(phases=["0th"], past_days=100)