|
1 | 1 | # methods/catalog/rbr/library.py |
2 | 2 | import math |
3 | | -from typing import Callable, Dict, Optional, Sequence, Tuple, Any |
| 3 | +from typing import Optional, Sequence, Any |
4 | 4 |
|
5 | 5 | import numpy as np |
6 | 6 | import torch |
@@ -238,15 +238,7 @@ def robust_bayesian_recourse( |
238 | 238 | random_state: Optional[int] = None, |
239 | 239 | verbose: bool = False, |
240 | 240 | ) -> np.ndarray: |
241 | | - """ |
242 | | - High-level function that matches the CARLA library-call pattern. |
243 | | - Parameters largely mirror the original code you provided. |
244 | | - - raw_model: object with .predict(np.ndarray) -> labels/probs |
245 | | - - x0: 1D numpy array (a single factual) |
246 | | - - cat_features_indices: indices of encoded categorical features to clamp/round |
247 | | - - train_data: numpy array (N, d) required (used to find boundary and feasible set) |
248 | | - Returns counterfactual as numpy array same shape as x0. |
249 | | - """ |
| 241 | + |
250 | 242 | # helper to call raw_model.predict consistently |
251 | 243 | def predict_fn_np(arr: np.ndarray) -> np.ndarray: |
252 | 244 | # raw_model might accept (n,d) and return probs or labels |
@@ -425,6 +417,4 @@ def projection(x, delta): |
425 | 417 |
|
426 | 418 | # ----------------------------- end of optimize() ----------------------- |
427 | 419 |
|
428 | | - # final clamping for feature valid ranges [0,1] if raw_model expects that (user may want different behaviour) |
429 | | - # NOTE: the CARLA wrapper can do final "check_counterfactuals" conversions; here we return raw vector |
430 | 420 | return cf |
0 commit comments