Skip to content

Commit

Permalink
raise exception when all features are dropped (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
pplonski committed Sep 14, 2020
1 parent fda7740 commit de82ad2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions supervised/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de82ad2

Please sign in to comment.