Slide 13
Slide 13 text
Python
Partial Dependence
@dataclass
class PartialDependence:
"""Partial Dependence (PD)"""
estimator: Any
X: np.ndarray
var_names: list[str]
def _counterfactual_prediction(
self,
idx_to_replace: int,
value_to_replace: float
) -> np.ndarray:
"""ある特徴量の値を置き換えたときの予測値を求める"""
X_replaced = self.X.copy()
X_replaced[:, idx_to_replace] = value_to_replace
y_pred = self.estimator.predict(X_replaced)
return y_pred
………
$
PD>
𝑥>
=
1
𝑁
*
?@"
A
+
𝑓(𝑥>
, 𝒙?,∖>
)