Instructions to use Delower/liver-extratrees-deployment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Delower/liver-extratrees-deployment with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Delower/liver-extratrees-deployment", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Download infer.py from Delower/liver-extratrees-deployment: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/Delower/liver-extratrees-deployment/resolve/main/infer.py
- Command line
-
hf download hf://Delower/liver-extratrees-deployment/infer.py
-
curl -L -o infer.py https://huggingface.co/Delower/liver-extratrees-deployment/resolve/main/infer.py
1.09 kB
| # infer.py — Liver ExtraTrees deployment model (Arch3 winner, refit). | |
| # Predicts the probability of the DILI-toxic class for one molecule. | |
| # | |
| # Usage: | |
| # python3 infer.py "CCO" -> prints the probability | |
| # from infer import predict; predict("CCO") | |
| # | |
| # Requires: scikit-learn, rdkit, joblib, numpy, and deployment_common.py | |
| # (shipped in this repo) on the import path — the shipped preprocessing | |
| # object (DescPrep) unpickles against that module. | |
| import os, sys | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| sys.path.insert(0, HERE) | |
| import numpy as np | |
| import joblib | |
| from deployment_common import featurize, prep_matrix | |
| _bundle = joblib.load(os.path.join(HERE, "model.joblib")) | |
| _model, _prep = _bundle["model"], _bundle["prep"] | |
| def predict(smiles): | |
| """Probability of the toxic (DILI-concern) class; None if unparseable.""" | |
| blocks, valid = featurize([smiles]) | |
| if not bool(valid[0]): | |
| return None | |
| X = prep_matrix(blocks, _prep, "fp_desc") | |
| return float(_model.predict_proba(X)[0, 1]) | |
| if __name__ == "__main__": | |
| print(predict(sys.argv[1])) | |