Skill Tracer
Skills › Scientific Agent Skills › deepchem › api_reference.md

api_reference.md

134 lines · skills/deepchem/references/api_reference.md at 5f2bc03

Open on GitHub
1# DeepChem 2.8.0 API contracts
2
3Reviewed 2026-09-30 against the released wheel/source and current official docs.
4`latest` documentation describes development builds; it is not the stable API.
5This is a selected contract reference, not a complete package catalogue.
6

DeepChem 2.8.0 API contracts

Reviewed 2026-09-30 against the released wheel/source and current official docs. latest documentation describes development builds; it is not the stable API. This is a selected contract reference, not a complete package catalogue.

Raw lines 1 to 6
7## Data and representations
8
9`CSVLoader(tasks=[...], feature_field='smiles', featurizer=...)` produces a
10`DiskDataset`. `NumpyDataset(X, y, w, ids)` wraps arrays. Keep all four aligned.
11Empty CSV labels are stored as placeholder zeros with zero weights; they are
12unmeasured, not negative assay results. Failed features can cause row removal.
13The bundled `load_csv` checks raw headers, numeric labels, SMILES and row counts.
15`SDFLoader`, `JsonLoader`, `ImageLoader`, `FASTALoader`, `FASTQLoader`, and alignment
16loaders have separate format contracts and optional dependencies. FASTA does not
17supply supervised property labels. `FASTALoader`'s legacy default is nucleotide
18encoding, not a ready-made protein-transformer input pipeline. There is no stable
19`dc.data.CIFLoader`: parse CIF with pymatgen and use a materials featurizer.
21| Model | Matching representation | Additional backend |
22|---|---|---|
23| `SklearnModel`, `MultitaskRegressor/Classifier` | `CircularFingerprint(size=2048)` or numeric descriptors | scikit-learn; Torch for multitask networks |
24| `GraphConvModel` | `ConvMolFeaturizer` (`'GraphConv'` MoleculeNet alias) | TensorFlow |
25| `GCNModel`, `GATModel` | `MolGraphConvFeaturizer()` (`GraphData`, 30 atom features) | Torch, DGL, DGL-LifeSci |
26| `AttentiveFPModel`, Torch `MPNNModel` | `MolGraphConvFeaturizer(use_edges=True)` (11 bond features) | Torch, DGL, DGL-LifeSci |
27| `DMPNNModel` | `DMPNNFeaturizer()` (133 atom, 14 bond features) | Torch, torch-geometric in 2.8.0 |
28| `GroverModel` | `GroverFeaturizer(features_generator=...)` | Torch |
29| `HuggingFaceModel` | Strings via `DummyFeaturizer`; tokenizer supplied separately | Torch, Transformers |
30| `BasicMolGANModel` | `MolGanFeaturizer`, adjacency/node tensors | Explicit Torch or TensorFlow implementation |
31| `CGCNNModel` | `CGCNNFeaturizer` on pymatgen `Structure` objects | pymatgen, Torch, DGL |
33Import Torch `MPNNModel`, `GroverModel`, and `BasicMolGANModel` from
34`deepchem.models.torch_models`; top-level aliases can be absent or select TensorFlow.
35Graph features are not interchangeable merely because their classes all represent molecules.
36`GroverFeaturizer` computes graph descriptors; it does not itself load learned embeddings.
38MoleculeNet `'ECFP'` means **1024** bits; the `CircularFingerprint` class defaults to
39**2048**. Pass an explicit object to keep training and prediction consistent.
40`'Raw'` constructs `RawFeaturizer()` whose default output is an RDKit Mol, not a
41SMILES string. Use `DummyFeaturizer()` for HF inputs or explicit
42`RawFeaturizer(smiles=True)` when canonicalized strings are intended.
44`RDKitDescriptors` feature inventory depends on the installed RDKit version;
45record feature names/order. `CoulombMatrix` needs conformer coordinates, units,
46and a consistent maximum atom count. `PowerTransformer` raises values to specified
47powers; it is not scikit-learn's Box-Cox/Yeo-Johnson transformer.

Data and representations

CSVLoader(tasks=[...], feature_field='smiles', featurizer=...) produces a DiskDataset. NumpyDataset(X, y, w, ids) wraps arrays. Keep all four aligned. Empty CSV labels are stored as placeholder zeros with zero weights; they are unmeasured, not negative assay results. Failed features can cause row removal. The bundled load_csv checks raw headers, numeric labels, SMILES and row counts.

SDFLoader, JsonLoader, ImageLoader, FASTALoader, FASTQLoader, and alignment loaders have separate format contracts and optional dependencies. FASTA does not supply supervised property labels. FASTALoader's legacy default is nucleotide encoding, not a ready-made protein-transformer input pipeline. There is no stable dc.data.CIFLoader: parse CIF with pymatgen and use a materials featurizer.

ModelMatching representationAdditional backend
SklearnModel, MultitaskRegressor/ClassifierCircularFingerprint(size=2048) or numeric descriptorsscikit-learn; Torch for multitask networks
GraphConvModelConvMolFeaturizer ('GraphConv' MoleculeNet alias)TensorFlow
GCNModel, GATModelMolGraphConvFeaturizer() (GraphData, 30 atom features)Torch, DGL, DGL-LifeSci
AttentiveFPModel, Torch MPNNModelMolGraphConvFeaturizer(use_edges=True) (11 bond features)Torch, DGL, DGL-LifeSci
DMPNNModelDMPNNFeaturizer() (133 atom, 14 bond features)Torch, torch-geometric in 2.8.0
GroverModelGroverFeaturizer(features_generator=...)Torch
HuggingFaceModelStrings via DummyFeaturizer; tokenizer supplied separatelyTorch, Transformers
BasicMolGANModelMolGanFeaturizer, adjacency/node tensorsExplicit Torch or TensorFlow implementation
CGCNNModelCGCNNFeaturizer on pymatgen Structure objectspymatgen, Torch, DGL

Import Torch MPNNModel, GroverModel, and BasicMolGANModel from deepchem.models.torch_models; top-level aliases can be absent or select TensorFlow. Graph features are not interchangeable merely because their classes all represent molecules. GroverFeaturizer computes graph descriptors; it does not itself load learned embeddings.

MoleculeNet 'ECFP' means 1024 bits; the CircularFingerprint class defaults to 2048. Pass an explicit object to keep training and prediction consistent. 'Raw' constructs RawFeaturizer() whose default output is an RDKit Mol, not a SMILES string. Use DummyFeaturizer() for HF inputs or explicit RawFeaturizer(smiles=True) when canonicalized strings are intended.

RDKitDescriptors feature inventory depends on the installed RDKit version; record feature names/order. CoulombMatrix needs conformer coordinates, units, and a consistent maximum atom count. PowerTransformer raises values to specified powers; it is not scikit-learn's Box-Cox/Yeo-Johnson transformer.

Raw lines 7 to 48
49## Splitting and transforms
51`ScaffoldSplitter` reads SMILES from **dataset.ids**. It keeps equal Bemis-Murcko
52scaffolds together; acyclic molecules can share an empty scaffold, causing very
53unequal or empty partitions. It does not remove duplicate measurements or prevent
54all chemical, temporal, assay, or patient leakage. Choose temporal/group/scaffold
55splits for the deployment question, check overlap and per-task class support, and
56save the actual IDs. `RandomStratifiedSplitter` balances nonzero task labels; it
57is not a general-purpose stratifier for arbitrary continuous outcomes.
59Fit `NormalizationTransformer(transform_y=True, dataset=train)` on training data
60only for continuous targets, then transform each split. Pass the same transformers
61to `model.predict(..., transformers=...)` and `model.evaluate(..., transformers=...)`
62for original-unit outputs. Do not normalize binary class labels. For missing-label
63regression, verify how your selected transformer estimates statistics; the bundled
64solubility custom-data path requires complete targets.

Splitting and transforms

ScaffoldSplitter reads SMILES from dataset.ids. It keeps equal Bemis-Murcko scaffolds together; acyclic molecules can share an empty scaffold, causing very unequal or empty partitions. It does not remove duplicate measurements or prevent all chemical, temporal, assay, or patient leakage. Choose temporal/group/scaffold splits for the deployment question, check overlap and per-task class support, and save the actual IDs. RandomStratifiedSplitter balances nonzero task labels; it is not a general-purpose stratifier for arbitrary continuous outcomes.

Fit NormalizationTransformer(transform_y=True, dataset=train) on training data only for continuous targets, then transform each split. Pass the same transformers to model.predict(..., transformers=...) and model.evaluate(..., transformers=...) for original-unit outputs. Do not normalize binary class labels. For missing-label regression, verify how your selected transformer estimates statistics; the bundled solubility custom-data path requires complete targets.

Raw lines 49 to 65
66## MoleculeNet loader contract
68`load_*(featurizer=..., splitter=..., transformers=..., reload=True)` normally
69returns `(tasks, (train, valid, test), fitted_transformers)`. `reload=True` reuses
70cached processed data; **False** rebuilds processing. It does not guarantee a new
71raw download. Record raw-source identity, local cache path, split IDs and package
72versions; a requested splitter is not proof of a paper's published split.
74Verified loader names used by the scripts:
76| Name | Loader | Task |
77|---|---|---|
78| Tox21 | `load_tox21` | 12 binary assays with missing labels |
79| BBBP | `load_bbbp` | binary |
80| BACE | `load_bace_classification` | binary; `load_bace_regression` is separate |
81| HIV | `load_hiv` | binary |
82| ESOL | `load_delaney` | log10 aqueous solubility in mol/L |
83| FreeSolv | `load_freesolv` | hydration free energy |
84| Lipophilicity | `load_lipo` | experimental logD |
86There is no `load_bace` alias. Other families include QM7/8/9, PDBbind,
87perovskite, `load_mp_formation_energy`, `load_mp_metallicity`, and USPTO; check the
88individual release-specific loader's source, featurizer, units, licensing and
89split options before use. No direct hosted inference API is called by these scripts.
90MoleculeNet loaders download public dataset files; HF `from_pretrained` resolves
91Hub repository assets, not an inference endpoint.

MoleculeNet loader contract

load_*(featurizer=..., splitter=..., transformers=..., reload=True) normally returns (tasks, (train, valid, test), fitted_transformers). reload=True reuses cached processed data; False rebuilds processing. It does not guarantee a new raw download. Record raw-source identity, local cache path, split IDs and package versions; a requested splitter is not proof of a paper's published split.

Verified loader names used by the scripts:

NameLoaderTask
Tox21load_tox2112 binary assays with missing labels
BBBPload_bbbpbinary
BACEload_bace_classificationbinary; load_bace_regression is separate
HIVload_hivbinary
ESOLload_delaneylog10 aqueous solubility in mol/L
FreeSolvload_freesolvhydration free energy
Lipophilicityload_lipoexperimental logD

There is no load_bace alias. Other families include QM7/8/9, PDBbind, perovskite, load_mp_formation_energy, load_mp_metallicity, and USPTO; check the individual release-specific loader's source, featurizer, units, licensing and split options before use. No direct hosted inference API is called by these scripts. MoleculeNet loaders download public dataset files; HF from_pretrained resolves Hub repository assets, not an inference endpoint.

Raw lines 66 to 92
93## Models, metrics and search
95`MultitaskRegressor` is a Torch model in this release. `SklearnModel` wraps numeric
96estimators; sparse multitask labels require one properly masked estimator per task
97or a model with verified masked-loss support. Do not feed binary and continuous
98outputs into the same plain regressor and call both scientifically equivalent tasks.
100Set `DMPNNModel(n_classes=2, mode='classification', ...)` for binary tasks; its
101released default is three classes. HF `HuggingFaceModel(model=network,
102tokenizer=tokenizer, task=...)` takes **objects**, not a Hub ID. The stable wrapper
103returns logits and uses the HF model's loss without applying `dataset.w`; the
104bundled HF path therefore rejects multiple tasks, missing labels and nonunit weights.
105GROVER uses `task='finetuning', mode='classification'/'regression'` and requires
106explicit feature dimensions and architecture. `model_dir` is an output/checkpoint
107location, not evidence that any pretrained weights were loaded.
109Use continuous probabilities for ROC-AUC/PR metrics and thresholded labels for
110accuracy/F1. Report the threshold and observed examples per task. AUC is undefined
111with one observed class; don't silently score it as zero. The bundled scorer reports
112per-task metrics and the number of valid tasks in each macro average. It reports
113average precision (scikit-learn), not a renamed trapezoidal PR AUC.
114`pearson_r2_score` is squared correlation, not R-squared; high correlation need not
115mean calibrated predictions. RMSE/MAE need original target units.
117`GridHyperparamOpt(model_builder)` invokes `model_builder(**model_params)`.
118`hyperparam_search(..., output_transformers=transformers, use_max=False)` minimizes
119an error metric. It returns `(best_model, best_params, all_scores)` where
120`all_scores` maps parameter combinations to validation scores; there is no
121`'best_validation_score'` special key. Keep the test set outside model selection.
122For custom Torch networks, use `dc.models.losses.L2Loss()` or a callable with the
123DeepChem `(outputs, labels, weights)` contract; `nn.MSELoss()` is not that callable.

Models, metrics and search

MultitaskRegressor is a Torch model in this release. SklearnModel wraps numeric estimators; sparse multitask labels require one properly masked estimator per task or a model with verified masked-loss support. Do not feed binary and continuous outputs into the same plain regressor and call both scientifically equivalent tasks.

Set DMPNNModel(n_classes=2, mode='classification', ...) for binary tasks; its released default is three classes. HF HuggingFaceModel(model=network, tokenizer=tokenizer, task=...) takes objects, not a Hub ID. The stable wrapper returns logits and uses the HF model's loss without applying dataset.w; the bundled HF path therefore rejects multiple tasks, missing labels and nonunit weights. GROVER uses task='finetuning', mode='classification'/'regression' and requires explicit feature dimensions and architecture. model_dir is an output/checkpoint location, not evidence that any pretrained weights were loaded.

Use continuous probabilities for ROC-AUC/PR metrics and thresholded labels for accuracy/F1. Report the threshold and observed examples per task. AUC is undefined with one observed class; don't silently score it as zero. The bundled scorer reports per-task metrics and the number of valid tasks in each macro average. It reports average precision (scikit-learn), not a renamed trapezoidal PR AUC. pearson_r2_score is squared correlation, not R-squared; high correlation need not mean calibrated predictions. RMSE/MAE need original target units.

GridHyperparamOpt(model_builder) invokes model_builder(**model_params). hyperparam_search(..., output_transformers=transformers, use_max=False) minimizes an error metric. It returns (best_model, best_params, all_scores) where all_scores maps parameter combinations to validation scores; there is no 'best_validation_score' special key. Keep the test set outside model selection. For custom Torch networks, use dc.models.losses.L2Loss() or a callable with the DeepChem (outputs, labels, weights) contract; nn.MSELoss() is not that callable.

Raw lines 93 to 124
125## Official sources
127- [Release metadata](https://pypi.org/project/deepchem/2.8.0/)
128- [Featurizers](https://deepchem.readthedocs.io/en/2.8.0/api_reference/featurizers.html)
129- [Models](https://deepchem.readthedocs.io/en/2.8.0/api_reference/models.html)
130- [Splitters](https://deepchem.readthedocs.io/en/2.8.0/api_reference/splitters.html)
131- [MoleculeNet](https://deepchem.readthedocs.io/en/2.8.0/api_reference/moleculenet.html)
132- [Released alias registry](https://github.com/deepchem/deepchem/blob/2.8.0/deepchem/molnet/load_function/molnet_loader.py)
133- [Released HF wrapper](https://github.com/deepchem/deepchem/blob/2.8.0/deepchem/models/torch_models/hf_models.py)
134- [Released hyperparameter search](https://github.com/deepchem/deepchem/blob/2.8.0/deepchem/hyper/grid_search.py)