Instructions to use tim-shu/drug-affinity-rf-baseline with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use tim-shu/drug-affinity-rf-baseline with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("tim-shu/drug-affinity-rf-baseline", "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
Drug affinity: frozen Random Forest baseline
Predict pKi from a complete small-molecule SMILES for one of 162 human protein targets. Higher pKi means tighter binding: pKi = −log10(Ki in mol/L). Select the protein by UniProt accession using targets.json.
The repository contains one trained RandomForestRegressor per target, from the frozen RF_full_descriptors, seed 42. Each forest has 100 trees, min_samples_leaf=1, max_features="sqrt". Inputs are chiral Morgan fingerprints (radius 2, 2048 bits) and eight properties: molecular weight, logP, TPSA, HBD, HBA, rotatable bonds, rings and heavy atoms. All disconnected components, charges and specified stereochemistry are retained. Protein IDs select a model; they are not numerical features.
Run
Download the model repository (about 362 MB of forests):
from huggingface_hub import snapshot_download
snapshot_download("tim-shu/drug-affinity-rf-baseline", local_dir="rf_baseline")
Install huggingface_hub for the download, then use Python 3.12 and the supplied inference dependencies:
python -m pip install -r rf_baseline/requirements.txt
python rf_baseline/affinity_predictor.py --target P00918 --smiles 'NS(=O)(=O)c1ccccc1'
Or in Python, after adding the downloaded folder to the import path:
import sys
sys.path.insert(0, "rf_baseline")
from affinity_predictor import AffinityBaseline
baseline = AffinityBaseline("rf_baseline")
pki = baseline.predict(["NS(=O)(=O)c1ccccc1"], target_id="P00918")
print(pki)
Weights use joblib serialization; use the exact scikit-learn and RDKit versions in requirements.txt. prediction_examples.json contains reference predictions for all supported targets, including multicomponent structures. verification.json records the local inference check; manifest.json lists SHA-256 checksums.
Data and evaluation
Training data and executed report, configuration baseline_benchmark: 204,847 pairs, with 163,330 train, 20,427 validation and 21,090 test pairs. Sources: ChEMBL, BindingDB and DrugCentral. Full-structure/protein pairs define labels; common chemical-scaffold groups define partitions. The weights are trained on train only, without a train+validation refit.
Selection used target-macro validation MAE averaged over seeds 42/43/44. The selection score was 0.594075 pKi. The uploaded seed-42 model has:
| Split | Macro MAE | Macro RMSE | Macro Spearman |
|---|---|---|---|
| Validation | 0.594005 | 0.775525 | 0.691222 |
| Test | 0.575935 | 0.747746 | 0.693083 |
Metrics weight protein targets equally. Some underlying data were examined in earlier project experiments, so test is not a new blind evaluation. final_baseline.json and training_manifest.json record exact selection, input hashes and training settings; reproducible training code is in the dataset repository's baseline_study/reproduction/ folder.
Scope
This is a research baseline for molecular affinity. It supports the listed proteins and does not generalize directly to unseen proteins. Accuracy can degrade for structures unlike training compounds; experimental conditions, pH and binding poses are not explicit inputs. Predicted affinity does not establish a therapeutic effect or a new clinical indication.
Source-data attribution and licenses are documented in the linked dataset repository.
- Downloads last month
- -