Skip to content

Commit

Permalink
fix: add target size check
Browse files Browse the repository at this point in the history
  • Loading branch information
Lopa10ko committed Sep 26, 2024
1 parent 5be9119 commit 266240b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def plot_feature_importance(self, importance_type='weight'):
@staticmethod
def convert_to_dataframe(data: Optional[InputData], identify_cats: bool):
dataframe = pd.DataFrame(data=data.features)
if data.target is not None:
if data.target is not None and data.target.size > 0:
dataframe['target'] = np.ravel(data.target)
else:
# TODO: temp workaround in case data.target is set to None intentionally
# TODO: temp workaround in case data.target is set to None or an empty sequence intentionally
# for test.integration.models.test_model.check_predict_correct
dataframe['target'] = np.zeros(len(data.features))

Expand Down Expand Up @@ -236,10 +236,10 @@ def set_eval_metric(n_classes):
@staticmethod
def convert_to_dataframe(data: Optional[InputData], identify_cats: bool):
dataframe = pd.DataFrame(data=data.features, columns=data.features_names)
if data.target is not None:
if data.target is not None and data.target.size > 0:
dataframe['target'] = np.ravel(data.target)
else:
# TODO: temp workaround in case data.target is set to None intentionally
# TODO: temp workaround in case data.target is set to None or an empty sequence intentionally
# for test.integration.models.test_model.check_predict_correct
dataframe['target'] = np.zeros(len(data.features))

Expand Down

0 comments on commit 266240b

Please sign in to comment.