|
14 | 14 | from scikeras.wrappers import KerasClassifier |
15 | 15 | from sklearn import metrics |
16 | 16 | from IPython.display import display |
| 17 | +from catboost import CatBoostError |
17 | 18 | from pandas.testing import assert_index_equal |
18 | 19 | from xgboost.core import XGBoostError |
19 | 20 |
|
@@ -326,6 +327,17 @@ def __init__( |
326 | 327 | # Pass reset data to search |
327 | 328 | current_algorithm = search.run_search(X_train_reset, y_train_reset) |
328 | 329 |
|
| 330 | + except CatBoostError as e: |
| 331 | + if "All features are either constant or ignored" in str(e): |
| 332 | + self.logger.error(f"CatBoostError occurred for {method_name}: {e}") |
| 333 | + self.logger.warning(f"Continuing despite CatBoost error...") |
| 334 | + # Set a default score and return to allow the pipeline to continue |
| 335 | + self.grid_search_cross_validate_score_result = 0.5 |
| 336 | + return |
| 337 | + else: |
| 338 | + # Re-raise other CatBoost errors |
| 339 | + raise e |
| 340 | + |
329 | 341 |
|
330 | 342 | except XGBoostError as e: |
331 | 343 | if 'cuda' in str(e).lower() or 'memory' in str(e).lower(): |
@@ -618,6 +630,14 @@ def adjust_param(param_value): |
618 | 630 | elif isinstance(parameter_space, dict) and 'subsample' in parameter_space: |
619 | 631 | parameter_space['subsample'] = adjust_param(parameter_space['subsample']) |
620 | 632 |
|
| 633 | + # Also adjust 'rsm' (colsample_bylevel) which can cause the same issue |
| 634 | + if isinstance(parameter_space, list): |
| 635 | + for params in parameter_space: |
| 636 | + if 'rsm' in params: |
| 637 | + params['rsm'] = adjust_param(params['rsm']) |
| 638 | + elif isinstance(parameter_space, dict) and 'rsm' in parameter_space: |
| 639 | + parameter_space['rsm'] = adjust_param(parameter_space['rsm']) |
| 640 | + |
621 | 641 |
|
622 | 642 | def dummy_auc() -> float: |
623 | 643 | """Returns a constant AUC score of 0.5. |
|
0 commit comments