subdataset = "machine-1-1" n_bins = 10 n_random_cuts = 100 point_adjustment = True iterate_threshold = True if __name__ == "__main__": logging.basicConfig( level=logging.INFO, format="%(asctime)s P%(process)d %(levelname)s %(message)s", ) # load dataset data_dict = load_dataset( dataset, subdataset, "all", ) x_train = data_dict["train"] x_test = data_dict["test"] x_test_labels = data_dict["test_labels"] # data preprocessing for MSCRED od = LODA(n_bins=n_bins, n_random_cuts=n_random_cuts) od.fit(x_train) # get outlier scores anomaly_score = od.decision_function(x_test) anomaly_label = x_test_labels
if __name__ == "__main__": config = ExpConfig() config.x_dim = get_data_dim(dataset) # print_with_title("Configurations", pformat(config.to_dict()), after="\n") # open the result object and prepare for result directories if specified results = MLResults(config.result_dir) results.save_config(config) # save experiment settings for review results.make_dirs(config.save_dir, exist_ok=True) logging.basicConfig( level="INFO", format="%(asctime)s [%(levelname)s] %(name)s: %(message)s") data_dict = load_dataset(dataset, subdataset) # preprocessing pp = preprocessor() data_dict = pp.normalize(data_dict) # generate sliding windows window_dict = generate_windows(data_dict, window_size=config.window_length, stride=5) # batch data x_train = DataGenerator(window_dict["train_windows"]) x_test = DataGenerator(window_dict["test_windows"]) test_labels = DataGenerator(window_dict["test_labels"])