From d77ecdb3aafaa93aabb618844efd66830ee8d74c Mon Sep 17 00:00:00 2001 From: Sergey Kasyanov Date: Mon, 14 Aug 2023 16:15:10 +0300 Subject: [PATCH] Fixes --- fedot/core/data/data_split.py | 2 +- fedot/core/optimisers/objective/data_source_splitter.py | 6 +++--- test/integration/api/test_api_utils.py | 2 +- test/unit/validation/test_table_cv.py | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fedot/core/data/data_split.py b/fedot/core/data/data_split.py index 0b85c0f864..3f2d389a0b 100644 --- a/fedot/core/data/data_split.py +++ b/fedot/core/data/data_split.py @@ -117,7 +117,7 @@ def _are_stratification_allowed(data: Union[InputData, MultiModalData], split_ra try: # fast way classes = np.unique(data.target, return_counts=True) - except: + except Exception: # slow way from collections import Counter classes = Counter(data.target) diff --git a/fedot/core/optimisers/objective/data_source_splitter.py b/fedot/core/optimisers/objective/data_source_splitter.py index 2c41d57a2c..70e5dd7e30 100644 --- a/fedot/core/optimisers/objective/data_source_splitter.py +++ b/fedot/core/optimisers/objective/data_source_splitter.py @@ -53,10 +53,10 @@ def build(self, data: Union[InputData, MultiModalData]) -> DataSource: # Check cv_folds if self.cv_folds is not None: - if not isinstance(self.cv_folds, int): - if self.cv_folds % 1 != 0: - raise ValueError(f"cv_folds is not integer: {self.cv_folds}") + try: self.cv_folds = int(self.cv_folds) + except ValueError: + raise ValueError(f"cv_folds is not integer: {self.cv_folds}") if self.cv_folds < 2: self.cv_folds = None if self.cv_folds > data.target.shape[0] - 1: diff --git a/test/integration/api/test_api_utils.py b/test/integration/api/test_api_utils.py index aa9aa4384a..fd2f7877ce 100644 --- a/test/integration/api/test_api_utils.py +++ b/test/integration/api/test_api_utils.py @@ -32,7 +32,7 @@ def test_output_binary_classification_correct(): task_type = 'classification' data = get_binary_classification_data() - + train_data, test_data = train_test_data_setup(data, shuffle=True) model = Fedot(problem=task_type, seed=1, timeout=0.1) diff --git a/test/unit/validation/test_table_cv.py b/test/unit/validation/test_table_cv.py index 6ebe511366..55be85451f 100644 --- a/test/unit/validation/test_table_cv.py +++ b/test/unit/validation/test_table_cv.py @@ -4,7 +4,6 @@ import pytest from golem.core.tuning.simultaneous import SimultaneousTuner -from sklearn.metrics import roc_auc_score as roc_auc from fedot.api.main import Fedot from fedot.core.data.data import InputData