Inference Using Models Trained with Anvil
Inference functions for trained models.
- openadmet.models.inference.inference.load_anvil_model_and_metadata(model_dir)[source]
Load the Anvil model from the specified path.
- Parameters:
model_dir (Union[str, Path]) – Path to the directory containing the trained model and its metadata.
- Returns:
A tuple containing the loaded model, feature object, metadata, and data specification.
- Return type:
tuple
- openadmet.models.inference.inference.predict(input_path: str, input_col: str, model_dir: str | Path | list[Union[str, pathlib._local.Path]], write_csv: bool = False, output_csv: str = None, debug: bool = False, accelerator: str = 'gpu', log: bool = True, aq_fxn_args: dict | None = None, **kwargs)[source]
Predict using a trained model.
- Parameters:
input_path (Union[str, Path, pd.DataFrame]) – Path to the input data file (CSV or SDF or parquet) or a pandas DataFrame.
input_col (str) – Name of the column containing SMILES strings.
model_dir (Union[str, Path, list[Union[str, Path]]]) – Path(s) to the directory(ies) containing the trained model(s) and their metadata.
write_csv (bool, optional) – Whether to write the output to a CSV file. Default is False.
output_csv (str, optional) – Path to the output CSV file. If None, defaults to ‘predictions.csv’ in the current directory. Default is None.
debug (bool, optional) – Whether to enable debug logging. Default is False.
accelerator (str, optional) – Accelerator to use for prediction (‘cpu’ or ‘gpu’). Default is ‘gpu’.
log (bool, optional) – Whether to enable logging. Default is True.
aq_fxn_args (dict, optional) – Dictionary of acquisition function names and their arguments to compute additional metrics. Default is None.
**kwargs – Additional keyword arguments.
- Returns:
DataFrame containing the input data along with prediction results.
- Return type:
pd.DataFrame