def testBatchModeParquetFolder(self): self.generate_input_folder('parquet') invoker.invoke(self.__input_path, "AnomalyAndMargin", self.__timestamp_column, self.__value_column, 66, self.__threshold, self.__sensitivity, self.__append_mode, self.__output_path) result = pd.read_csv(f"{self.__output_path}/output.csv") self.assertEqual(result.shape[0], 600) self.assertTrue('value' in result.columns) self.assertTrue('isAnomaly' in result.columns) self.assertTrue('score' in result.columns) self.assertTrue('expectedValue' in result.columns) self.assertTrue('upperBoundary' in result.columns) self.assertTrue('lowerBoundary' in result.columns)
def testAnomalyOnlyModeCsvFolder(self): self.generate_input_folder() invoker.invoke(self.__input_path, self.__detect_mode, self.__timestamp_column, self.__value_column, self.__batch_size, self.__threshold, self.__sensitivity, self.__append_mode, self.__output_path) result = pd.read_csv(f"{self.__output_path}/output.csv") self.assertEqual(result.shape[0], 600) self.assertTrue('value' in result.columns) self.assertTrue('isAnomaly' in result.columns) self.assertTrue('score' in result.columns) self.assertTrue('expectedValue' not in result.columns) self.assertTrue('upperBoundary' not in result.columns) self.assertTrue('lowerBoundary' not in result.columns)
def testAnomalyOnlyModeParquetFile(self): df = self.generate_input_data_frame() df.to_parquet(self.__input_parquet_file, index=False) invoker.invoke(self.__input_parquet_file, self.__detect_mode, self.__timestamp_column, self.__value_column, self.__batch_size, self.__threshold, self.__sensitivity, self.__append_mode, self.__output_path) result = pd.read_csv(f"{self.__output_path}/output.csv") self.assertEqual(result.shape[0], 200) self.assertTrue('value' in result.columns) self.assertTrue('isAnomaly' in result.columns) self.assertTrue('score' in result.columns) self.assertTrue('expectedValue' not in result.columns) self.assertTrue('upperBoundary' not in result.columns) self.assertTrue('lowerBoundary' not in result.columns)
def testBatchModeCsvFile(self): df = self.generate_input_data_frame() df.to_csv(self.__input_csv_file, index=False) invoker.invoke(self.__input_csv_file, "AnomalyAndMargin", self.__timestamp_column, self.__value_column, 66, self.__threshold, self.__sensitivity, self.__append_mode, self.__output_path) result = pd.read_csv(f"{self.__output_path}/output.csv") self.assertEqual(result.shape[0], 200) self.assertTrue('value' in result.columns) self.assertTrue('isAnomaly' in result.columns) self.assertTrue('score' in result.columns) self.assertTrue('expectedValue' in result.columns) self.assertTrue('upperBoundary' in result.columns) self.assertTrue('lowerBoundary' in result.columns)
def testAnomalyAndMargin(self): df = pd.DataFrame() df['timestamp'] = pd.date_range(start='2020-01-01', periods=200, freq='1D') df['value'] = np.sin(np.linspace(1, 20, 200)) save_data_frame_to_directory(self.__input_path, df) invoker.invoke(self.__input_path, "AnomalyAndMargin", self.__timestamp_column, self.__value_column, self.__batch_size, self.__threshold, self.__sensitivity, self.__append_mode, self.compute_stats_in_visualization, self.__output_path) result = load_data_frame_from_directory(self.__output_path).data self.assertEqual(result.shape[0], 200) self.assertTrue('value' in result.columns) self.assertTrue('isAnomaly' in result.columns) self.assertTrue('score' in result.columns) self.assertTrue('expectedValue' in result.columns) self.assertTrue('upperBoundary' in result.columns) self.assertTrue('lowerBoundary' in result.columns)