From 7bb8ba0cb0ebeca0652ad2e71cdf83a5f6edae63 Mon Sep 17 00:00:00 2001 From: valer1435 Date: Tue, 8 Aug 2023 09:55:23 +0300 Subject: [PATCH] made working example --- examples/anomaly_detection/detection_classification.py | 6 +++--- .../architecture/experiment/TimeSeriesClassifierPreset.py | 7 +++---- fedot_ind/core/models/statistical/StatsExtractor.py | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/anomaly_detection/detection_classification.py b/examples/anomaly_detection/detection_classification.py index b158ec511..f23bdfebf 100644 --- a/examples/anomaly_detection/detection_classification.py +++ b/examples/anomaly_detection/detection_classification.py @@ -52,8 +52,8 @@ def generate_time_series(to_plot: bool = True, label=cls) for cls in anomaly_intervals.keys()] for anomaly_class, intervals in anomaly_intervals.items(): - for interval in intervals.split(', '): - start_idx, end_idx = map(int, interval.split(':')) + for interval in intervals: + start_idx, end_idx = map(int, interval) ax.axvspan(start_idx, end_idx, alpha=0.3, color=color_dict[anomaly_class]) plt.legend(handles=set(legend_patches)) @@ -69,7 +69,7 @@ def generate_colors(num_colors): if __name__ == "__main__": - time_series, anomaly_intervals = generate_time_series(to_plot=False, + time_series, anomaly_intervals = generate_time_series(to_plot=True, ts_length=1000, num_anomaly_classes=4, num_of_anomalies=50) diff --git a/fedot_ind/core/architecture/experiment/TimeSeriesClassifierPreset.py b/fedot_ind/core/architecture/experiment/TimeSeriesClassifierPreset.py index 75f085ea2..ed18df338 100644 --- a/fedot_ind/core/architecture/experiment/TimeSeriesClassifierPreset.py +++ b/fedot_ind/core/architecture/experiment/TimeSeriesClassifierPreset.py @@ -15,7 +15,6 @@ from fedot.core.repository.quality_metrics_repository import ClassificationMetricsEnum from fedot.core.repository.tasks import Task, TaskTypesEnum from golem.core.tuning.simultaneous import SimultaneousTuner -from golem.core.tuning.sequential import SequentialTuner from fedot_ind.api.utils.saver_collections import ResultSaver from fedot_ind.core.architecture.postprocessing.Analyzer import PerformanceAnalyzer @@ -210,8 +209,8 @@ def fit(self, features, 'mlp', 'knn', 'lgbm', - 'pca'] - , **self.model_params) + 'pca'], + **self.model_params) self.predictor.fit(train_data_preprocessed) @@ -247,8 +246,8 @@ def predict(self, features: pd.DataFrame, target: np.array) -> dict: data_type=test_data_preprocessed.data_type, task=test_data_preprocessed.task) - self.prediction_label_baseline = self.baseline_model.predict(self.test_data_preprocessed).predict self.prediction_label = self.predictor.predict(self.test_data_preprocessed) + self.prediction_label_baseline = self.baseline_model.predict(self.test_data_preprocessed).predict return self.prediction_label diff --git a/fedot_ind/core/models/statistical/StatsExtractor.py b/fedot_ind/core/models/statistical/StatsExtractor.py index bc6db9683..1e06e7ebb 100644 --- a/fedot_ind/core/models/statistical/StatsExtractor.py +++ b/fedot_ind/core/models/statistical/StatsExtractor.py @@ -50,7 +50,7 @@ def _transform(self, input_data: InputData) -> np.array: # predict = self.drop_features(predict=predict, # columns=stat_features, # n_components=n_components) - if predict.shape[1] == 29: + if predict.shape[1] == 36: print('a') return predict