Check for NaNs in the data, since sklearn.LinearRegression cannot handle them.

rapids
junos 2021-08-21 17:45:23 +02:00
parent 0b85ee8fdc
commit 8507ff5761
1 changed files with 6 additions and 3 deletions

View File

@ -180,12 +180,15 @@ class ModelValidation:
def cross_validate(self):
if self.model is None:
raise ValueError(
raise TypeError(
"Please set self.model first, e.g. self.model = sklearn.linear_model.LinearRegression()"
)
# TODO Is ValueError appropriate here?
if self.cv is None:
raise ValueError("Please use set_cv_method() first.")
raise TypeError("Please use set_cv_method() first.")
if self.X.isna().any().any() or self.y.isna().any().any():
raise ValueError(
"NaNs were found in either X or y. Please, check your data before continuing."
)
return cross_val_score(
estimator=self.model,
X=self.X,