Instructions to use Delower/kidney-arch3-bagging-deployment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Delower/kidney-arch3-bagging-deployment with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Delower/kidney-arch3-bagging-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 predict.py from Delower/kidney-arch3-bagging-deployment: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/Delower/kidney-arch3-bagging-deployment/resolve/main/predict.py
- Command line
-
hf download hf://Delower/kidney-arch3-bagging-deployment/predict.py
-
curl -L -o predict.py https://huggingface.co/Delower/kidney-arch3-bagging-deployment/resolve/main/predict.py
1.56 kB
| # predict.py — Kidney Arch3 LazyPredict-best deployment model | |
| # (BaggingClassifier, the full-pool sweep winner). Predicts the | |
| # probability of the kidney-toxic (nephrotoxicity-concern) class for | |
| # one molecule. | |
| # | |
| # Usage: | |
| # python3 predict.py "CCO" -> prints the probability | |
| # from predict import predict; predict("CCO") | |
| # from predict import predict_many; predict_many([smi1, smi2]) | |
| # | |
| # 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. | |
| # | |
| # Featurization is the deployment pipeline's own code: featurize / | |
| # prep_matrix from deployment_common.py; prediction replicates | |
| # screen_leads.py's arch3_prob exactly (fp_desc block). | |
| 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_many(smiles_list): | |
| """Probabilities of the toxic class; None where unparseable.""" | |
| blocks, valid = featurize(list(smiles_list)) | |
| X = prep_matrix(blocks, _prep, "fp_desc") | |
| p = _model.predict_proba(X)[:, 1] | |
| return [float(v) if ok else None for v, ok in zip(p, valid)] | |
| def predict(smiles): | |
| """Probability of the toxic class; None if unparseable.""" | |
| return predict_many([smiles])[0] | |
| if __name__ == "__main__": | |
| print(predict(sys.argv[1])) | |