Skip to content

Commit

Permalink
NAs detection #45
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyangkang committed May 3, 2024
1 parent 8ee8e7b commit 1e8bc83
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stemflow/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def check_X_train(X_train):
if not isinstance(X_train, pd.core.frame.DataFrame):
raise TypeError(f"Input X should be type 'pd.core.frame.DataFrame'. Got {str(type_X_train)}")

if np.sum(np.isnan(X_train)) > 0:
raise ValueError(
"NAs (missing values) detected in input data. stemflow do not support NAs input. Consider filling them with values (e.g., -1 or mean values) or removing the rows."
)


def check_y_train(y_train):
type_y_train = str(type(y_train))
Expand All @@ -131,6 +136,9 @@ def check_y_train(y_train):
f"Input y_train should be type 'pd.core.frame.DataFrame' or 'pd.core.frame.Series', or 'np.ndarray'. Got {str(type_y_train)}"
)

if np.sum(np.isnan(y_train)) > 0:
raise ValueError("NAs (missing values) detected in input y data. Consider deleting these rows.")


def check_X_test(X_test):
check_X_train(X_test)
Expand Down

0 comments on commit 1e8bc83

Please sign in to comment.