chemprop.callbacks.interpret#
Attributes#
Classes#
A |
Module Contents#
- chemprop.callbacks.interpret.logger#
- class chemprop.callbacks.interpret.MyersonExplainerCallback(model_paths, output, sampling_threshold=20, save_as_json=False)[source]#
Bases:
lightning.pytorch.callbacks.CallbackA
MyersonExplainerCallbackcalculates and saves Myerson explanations during a predict call.The explanations are saved as a compressed NumPy archive (
.npzfile) by default. Each molecule’s explanation is saved as a separate array within the archive (e.g.,arr_0,arr_1, etc.). Each array will be a 1D or 2D NumPy array of shapenum_atoms(for regression or binary classification) ornum_atoms x num_classes(for multi-label classification) containing the explanation for one molecule.Alternatively, if
save_as_jsonis set to True, the explanations are saved as a JSON file. The JSON file contains a list of explanations, where each explanation corresponds to a molecule. For 2D explanations (multi-label), each inner list represents a column (i.e., attributions for a specific label across all atoms).- Parameters:
model_paths (list[Path]) – A list of paths to the models to be used for explanations.
output (Path) – The path to the output file for saving predictions, used to derive the explanation file path.
sampling_threshold (int, default=20) – The maximum number of atoms in a molecule for which to use the exact explainer. For molecules with more atoms, a sampling-based explainer is used.
save_as_json (bool, default=False) – If True, save the explanations as a JSON file instead of a npz file.
- sampling_threshold = 20#
- save_as_json = False#
- model_counter = 0#
- max_model_counter = -1#
- output_filename_base#
- output_path_dir#