Skip to content

Commit

Permalink
Use same InputDataError type for binary features with more than two d…
Browse files Browse the repository at this point in the history
…istinct categories.
  • Loading branch information
dantreiman committed Oct 18, 2022
1 parent d0c5118 commit 24083e1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ludwig/features/binary_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
TIED,
TYPE,
)
from ludwig.error import InputDataError
from ludwig.features.base_feature import BaseFeatureMixin, InputFeature, OutputFeature, PredictModule
from ludwig.schema.features.binary_feature import BinaryInputFeatureConfig, BinaryOutputFeatureConfig
from ludwig.utils import calibration, output_feature_utils, strings_utils
Expand Down Expand Up @@ -165,9 +166,8 @@ def get_feature_meta(column: DataFrame, preprocessing_parameters: Dict[str, Any]

distinct_values = backend.df_engine.compute(column.drop_duplicates())
if len(distinct_values) > 2:
raise ValueError(
f"Binary feature column {column.name} expects 2 distinct values, "
f"found: {distinct_values.values.tolist()}"
raise InputDataError(
column.name, BINARY, f"expects 2 distinct values, found {distinct_values.values.tolist()}"
)
if preprocessing_parameters["fallback_true_label"]:
fallback_true_label = preprocessing_parameters["fallback_true_label"]
Expand Down

0 comments on commit 24083e1

Please sign in to comment.