matcha.explainability.lime
Attributes
Classes
Local Interpretable Model-agnostic Explanations for molecular predictions. |
Module Contents
- matcha.explainability.lime.logger
- class matcha.explainability.lime.LIME(descriptor_set: list[str] | None = None, fingerprint_params: dict | None = None, scale_coeff: bool = True, use_fingerprints: bool = False)[source]
Local Interpretable Model-agnostic Explanations for molecular predictions.
Fits bootstrapped Ridge regression models on molecular descriptors or ECFP fingerprints to identify which features most influence a prediction. Coefficients are optionally scaled to sum to 1 for interpretability.
- get_envs_and_weights(mol: rdkit.Chem.rdchem.Mol, out: pandas.DataFrame)[source]
Extracts atomic environments and weights for a molecule given a lime analysis result
- Parameters:
mol (Mol) – rdkit molecule
out (pd.DataFrame) – lime analysis result
- explain(X: list[rdkit.Chem.rdchem.Mol], Y: numpy.ndarray, bootstrap_num: int = 25) pandas.DataFrame[source]
Perform LIME analysis on molecules.
Fits bootstrapped Ridge regression models to explain how molecular descriptors (or fingerprint bits) relate to the target values. Returns a DataFrame of coefficients sorted by importance.
- Parameters:
- Returns:
DataFrame with columns
Descriptor,Coefficient, andStandard deviation, sorted by coefficient magnitude. The last row contains the local fit R-squared summary.