def test_detect_anomalies_saved_orion(self, tmpdir): orion_path = os.path.join(tmpdir, 'orion.pkl') functional.fit_pipeline(self.clean, 'dummy', save_path=orion_path) anomalies = functional.detect_anomalies( data=self.anomalous, pipeline=orion_path, ) pd.testing.assert_frame_equal(self.events, anomalies)
def test_fit_pipeline_save_path(self, tmpdir): path = os.path.join(tmpdir, 'some/path.pkl') returned = functional.fit_pipeline(self.data, 'dummy', save_path=path) assert returned is None assert os.path.isfile(path)
def test_fit_pipeline_name(self): orion = functional.fit_pipeline(self.data, 'dummy') assert isinstance(orion, Orion) assert orion._pipeline == 'dummy' assert orion._fitted assert orion._hyperparameters is None
def test_detect_anomalies_fitted_orion(self): orion = functional.fit_pipeline(self.clean, 'dummy') anomalies = functional.detect_anomalies( data=self.anomalous, pipeline=orion, ) pd.testing.assert_frame_equal(self.events, anomalies)
def test_fit_pipeline_dict(self): pipeline = load_pipeline('dummy') orion = functional.fit_pipeline(self.data, pipeline) assert isinstance(orion, Orion) assert orion._pipeline == pipeline assert orion._fitted assert orion._hyperparameters is None
def test_fit_pipeline_csv(self, tmpdir): data_path = os.path.join(tmpdir, 'data.csv') self.data.to_csv(data_path, index=False) orion = functional.fit_pipeline(data_path, 'dummy') assert isinstance(orion, Orion) assert orion._pipeline == 'dummy' assert orion._fitted assert orion._hyperparameters is None
def test_fit_pipeline_hyperparams_dict(self): hyperparams = { "orion.primitives.detectors.ThresholdDetector#1": { "ratio": 0.9 } } orion = functional.fit_pipeline(self.data, 'dummy', hyperparams) assert isinstance(orion, Orion) assert orion._pipeline == 'dummy' assert orion._fitted assert orion._hyperparameters == hyperparams
def test_fit_pipeline_hyperparams_json(self, tmpdir): hyperparams = { "orion.primitives.detectors.ThresholdDetector#1": { "ratio": 0.9 } } hyperparams_path = os.path.join(tmpdir, 'hyperparams.json') with open(hyperparams_path, 'w') as json_file: json.dump(hyperparams, json_file) orion = functional.fit_pipeline(self.data, 'dummy', hyperparams_path) assert isinstance(orion, Orion) assert orion._pipeline == 'dummy' assert orion._fitted assert orion._hyperparameters == hyperparams