From 5a2f45d409f17172d26719ac47ac0c1b5bb3cd93 Mon Sep 17 00:00:00 2001 From: Ellert van der Velden Date: Mon, 9 Dec 2019 14:37:38 +1100 Subject: [PATCH 1/2] Set cv_score to `-np.inf` if OLS fit fails --- mlxtend/feature_selection/sequential_feature_selector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index b65c0f696..f64e215b1 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -32,7 +32,8 @@ def _calc_score(selector, X, y, indices, groups=None, **fit_params): scoring=selector.scorer, n_jobs=1, pre_dispatch=selector.pre_dispatch, - fit_params=fit_params) + fit_params=fit_params, + error_score=-np.inf) else: selector.est_.fit(X[:, indices], y, **fit_params) scores = np.array([selector.scorer(selector.est_, X[:, indices], y)]) From 9a6136ff40b6b28ceb4a0d21141a82ca3989d953 Mon Sep 17 00:00:00 2001 From: Ellert van der Velden Date: Mon, 9 Dec 2019 14:56:49 +1100 Subject: [PATCH 2/2] Set cv_score to `-np.inf` if OLS fit fails --- mlxtend/feature_selection/exhaustive_feature_selector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/exhaustive_feature_selector.py b/mlxtend/feature_selection/exhaustive_feature_selector.py index 93552edf4..754ea87dd 100644 --- a/mlxtend/feature_selection/exhaustive_feature_selector.py +++ b/mlxtend/feature_selection/exhaustive_feature_selector.py @@ -34,7 +34,8 @@ def _calc_score(selector, X, y, indices, groups=None, **fit_params): scoring=selector.scorer, n_jobs=1, pre_dispatch=selector.pre_dispatch, - fit_params=fit_params) + fit_params=fit_params, + error_score=-np.inf) else: selector.est_.fit(X[:, indices], y, **fit_params) scores = np.array([selector.scorer(selector.est_, X[:, indices], y)])