From de82ad26878bf39be0c0385a42d6ea74d411fd14 Mon Sep 17 00:00:00 2001 From: Piotrek Date: Mon, 14 Sep 2020 21:06:46 +0200 Subject: [PATCH] raise exception when all features are dropped (#184) --- supervised/preprocessing/preprocessing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/supervised/preprocessing/preprocessing.py b/supervised/preprocessing/preprocessing.py index 3a4621d3..94bf5a33 100644 --- a/supervised/preprocessing/preprocessing.py +++ b/supervised/preprocessing/preprocessing.py @@ -2,6 +2,7 @@ import pandas as pd import numpy as np import warnings +import logging from supervised.preprocessing.preprocessing_utils import PreprocessingUtils from supervised.preprocessing.preprocessing_categorical import PreprocessingCategorical @@ -20,9 +21,8 @@ MULTICLASS_CLASSIFICATION, REGRESSION, ) - -import logging from supervised.utils.config import LOG_LEVEL +from supervised.exceptions import AutoMLException logger = logging.getLogger(__name__) logger.setLevel(LOG_LEVEL) @@ -251,6 +251,10 @@ def fit_and_transform(self, X_train, y_train): if self._drop_features: available_cols = X_train.columns.tolist() drop_cols = [c for c in self._drop_features if c in available_cols] + if len(drop_cols) == X_train.shape[1]: + raise AutoMLException( + "All features are droppped! Your data looks like random data." + ) if drop_cols: X_train.drop(drop_cols, axis=1, inplace=True) self._drop_features = drop_cols