def init_od_prophet(state_dict: Dict) -> OutlierProphet: """ Initialize OutlierProphet. Parameters ---------- state_dict Dictionary containing the parameter values. Returns ------- Initialized OutlierProphet instance. """ od = OutlierProphet(cap=state_dict['cap']) od.model = state_dict['model'] return od
def test_prophet(prophet_params): import fbprophet growth, return_instance_score, return_forecast = prophet_params od = OutlierProphet(growth=growth) assert isinstance(od.model, fbprophet.forecaster.Prophet) assert od.meta == {'name': 'OutlierProphet', 'detector_type': 'offline', 'data_type': 'time-series', 'version': __version__} if growth == 'logistic': df_fit['cap'] = 10. df_test['cap'] = 10. od.fit(df_fit) forecast = od.score(df_test) fcst_cols = list(forecast.columns) check_cols = ['ds', 'yhat', 'yhat_lower', 'yhat_upper', 'score', 'y'] assert all(check_col in fcst_cols for check_col in check_cols) od_preds = od.predict(df_test, return_instance_score=return_instance_score, return_forecast=return_forecast) assert od_preds['meta'] == od.meta assert (od_preds['data']['is_outlier']['ds'] == df_test['ds']).all() assert od_preds['data']['is_outlier']['is_outlier'].shape[0] == df_test['ds'].shape[0] if not return_instance_score: assert od_preds['data']['instance_score'] is None if not return_forecast: with pytest.raises(KeyError): od_preds['data']['forecast']
OutlierAEGMM(threshold=threshold, gmm_density_net=gmm_density_net, n_gmm=n_gmm, **kwargs), OutlierVAE(threshold=threshold, latent_dim=latent_dim, samples=samples, **kwargs), OutlierAE(threshold=threshold, **kwargs), OutlierVAEGMM(threshold=threshold, gmm_density_net=gmm_density_net, n_gmm=n_gmm, latent_dim=latent_dim, samples=samples, **kwargs), OutlierProphet(threshold=.7, growth='logistic'), SpectralResidual(threshold=threshold, window_amp=10, window_local=10), OutlierSeq2Seq(input_dim, seq_len, threshold=threshold, threshold_net=threshold_net, latent_dim=latent_dim) ] n_tests = len(detector) @pytest.fixture def select_detector(request): return detector[request.param]