Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Molecular machine learning toolkit. Property prediction (ADMET, toxicity), GNNs (GCN, MPNN), MoleculeNet benchmarks, pretrained models, featurization, for drug discovery ML.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | — | — |
| case-17 | ✗→✓ | ▲ Improved | — | — |
| case-05 | ✗→✓ | ▲ Improved | — | — |
| case-14 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
DeepChem is a comprehensive Python library for applying machine learning to chemistry, materials science, and biology. Enable molecular property prediction, drug discovery, materials design, and biomolecule analysis through specialized neural networks, molecular featurization methods, and pretrained models.
This skill should be used when:
DeepChem provides specialized loaders for various chemical data formats:
pythonimport deepchem as dc # Load CSV with SMILES featurizer = dc.feat.CircularFingerprint(radius=2, size=2048) loader = dc.data.CSVLoader( tasks=['solubility', 'toxicity'], feature_field='smiles', featurizer=featurizer ) dataset = loader.create_dataset('molecules.csv') # Load SDF files loader = dc.data.SDFLoader(tasks=['activity'], featurizer=featurizer) dataset = loader.create_dataset('compounds.sdf') # Load protein sequences loader = dc.data.FASTALoader() dataset = loader.create_dataset('proteins.fasta')
Key Loaders:
CSVLoader: Tabular data with molecular identifiersSDFLoader: Molecular structure filesFASTALoader: Protein/DNA sequencesImageLoader: Molecular imagesJsonLoader: JSON-formatted datasetsConvert molecules into numerical representations for ML models.
Is the model a graph neural network?
├─ YES → Use graph featurizers
│ ├─ Standard GNN → MolGraphConvFeaturizer
│ ├─ Message passing → DMPNNFeaturizer
│ └─ Pretrained → GroverFeaturizer
│
└─ NO → What type of model?
├─ Traditional ML (RF, XGBoost, SVM)
│ ├─ Fast baseline → CircularFingerprint (ECFP)
│ ├─ Interpretable → RDKitDescriptors
│ └─ Maximum coverage → MordredDescriptors
│
├─ Deep learning (non-graph)
│ ├─ Dense networks → CircularFingerprint
│ └─ CNN → SmilesToImage
│
├─ Sequence models (LSTM, Transformer)
│ └─ SmilesToSeq
│
└─ 3D structure analysis
└─ CoulombMatrixpython# Fingerprints (for traditional ML) fp = dc.feat.CircularFingerprint(radius=2, size=2048) # Descriptors (for interpretable models) desc = dc.feat.RDKitDescriptors() # Graph features (for GNNs) graph_feat = dc.feat.MolGraphConvFeaturizer() # Apply featurization features = fp.featurize(['CCO', 'c1ccccc1'])
Selection Guide:
See references/api_reference.md for complete featurizer documentation.
Critical: For drug discovery tasks, use ScaffoldSplitter to prevent data leakage from similar molecular structures appearing in both training and test sets.
python# Scaffold splitting (recommended for molecules) splitter = dc.splits.ScaffoldSplitter() train, valid, test = splitter.train_valid_test_split( dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1 ) # Random splitting (for non-molecular data) splitter = dc.splits.RandomSplitter() train, test = splitter.train_test_split(dataset) # Stratified splitting (for imbalanced classification) splitter = dc.splits.RandomStratifiedSplitter() train, test = splitter.train_test_split(dataset)
Available Splitters:
ScaffoldSplitter: Split by molecular scaffolds (prevents leakage)ButinaSplitter: Clustering-based molecular splittingMaxMinSplitter: Maximize diversity between setsRandomSplitter: Random splittingRandomStratifiedSplitter: Preserves class distributions| Dataset Size | Task | Recommended Model | Featurizer | |-------------|------|-------------------|------------| | < 1K samples | Any | SklearnModel (RandomForest) | CircularFingerprint | | 1K-100K | Classification/Regression | GBDTModel or MultitaskRegressor | CircularFingerprint | | > 100K | Molecular properties | GCNModel, AttentiveFPModel, DMPNNModel | MolGraphConvFeaturizer | | Any (small preferred) | Transfer learning | ChemBERTa, GROVER, MolFormer | Model-specific | | Crystal structures | Materials properties | CGCNNModel, MEGNetModel | Structure-based | | Protein sequences | Protein properties | ProtBERT | Sequence-based |
pythonfrom sklearn.ensemble import RandomForestRegressor # Wrap scikit-learn model sklearn_model = RandomForestRegressor(n_estimators=100) model = dc.models.SklearnModel(model=sklearn_model) model.fit(train)
python# Multitask regressor (for fingerprints) model = dc.models.MultitaskRegressor( n_tasks=2, n_features=2048, layer_sizes=[1000, 500], dropouts=0.25, learning_rate=0.001 ) model.fit(train, nb_epoch=50)
python# Graph Convolutional Network model = dc.models.GCNModel( n_tasks=1, mode='regression', batch_size=128, learning_rate=0.001 ) model.fit(train, nb_epoch=50) # Graph Attention Network model = dc.models.GATModel(n_tasks=1, mode='classification') model.fit(train, nb_epoch=50) # Attentive Fingerprint model = dc.models.AttentiveFPModel(n_tasks=1, mode='regression') model.fit(train, nb_epoch=50)
Quick access to 30+ curated benchmark datasets with standardized train/valid/test splits:
python# Load benchmark dataset tasks, datasets, transformers = dc.molnet.load_tox21( featurizer='GraphConv', # or 'ECFP', 'Weave', 'Raw' splitter='scaffold', # or 'random', 'stratified' reload=False ) train, valid, test = datasets # Train and evaluate model = dc.models.GCNModel(n_tasks=len(tasks), mode='classification') model.fit(train, nb_epoch=50) metric = dc.metrics.Metric(dc.metrics.roc_auc_score) test_score = model.evaluate(test, [metric])
Common Datasets:
load_tox21(), load_bbbp(), load_hiv(), load_clintox()load_delaney(), load_freesolv(), load_lipo()load_qm7(), load_qm8(), load_qm9()load_perovskite(), load_bandgap(), load_mp_formation_energy()See references/api_reference.md for complete dataset list.
Leverage pretrained models for improved performance, especially on small datasets:
python# ChemBERTa (BERT pretrained on 77M molecules) model = dc.models.HuggingFaceModel( model='seyonec/ChemBERTa-zinc-base-v1', task='classification', n_tasks=1, learning_rate=2e-5 # Lower LR for fine-tuning ) model.fit(train, nb_epoch=10) # GROVER (graph transformer pretrained on 10M molecules) model = dc.models.GroverModel( task='regression', n_tasks=1 ) model.fit(train, nb_epoch=20)
When to use transfer learning:
Use the scripts/transfer_learning.py script for guided transfer learning workflows.
python# Define metrics classification_metrics = [ dc.metrics.Metric(dc.metrics.roc_auc_score, name='ROC-AUC'), dc.metrics.Metric(dc.metrics.accuracy_score, name='Accuracy'), dc.metrics.Metric(dc.metrics.f1_score, name='F1') ] regression_metrics = [ dc.metrics.Metric(dc.metrics.r2_score, name='R²'), dc.metrics.Metric(dc.metrics.mean_absolute_error, name='MAE'), dc.metrics.Metric(dc.metrics.root_mean_squared_error, name='RMSE') ] # Evaluate train_scores = model.evaluate(train, classification_metrics) test_scores = model.evaluate(test, classification_metrics)
python# Predict on test set predictions = model.predict(test) # Predict on new molecules new_smiles = ['CCO', 'c1ccccc1', 'CC(C)O'] new_features = featurizer.featurize(new_smiles) new_dataset = dc.data.NumpyDataset(X=new_features) # Apply same transformations as training for transformer in transformers: new_dataset = transformer.transform(new_dataset) predictions = model.predict(new_dataset)
For evaluating a model on standard benchmarks:
pythonimport deepchem as dc # 1. Load benchmark tasks, datasets, _ = dc.molnet.load_bbbp( featurizer='GraphConv', splitter='scaffold' ) train, valid, test = datasets # 2. Train model model = dc.models.GCNModel(n_tasks=len(tasks), mode='classification') model.fit(train, nb_epoch=50) # 3. Evaluate metric = dc.metrics.Metric(dc.metrics.roc_auc_score) test_score = model.evaluate(test, [metric]) print(f"Test ROC-AUC: {test_score}")
For training on custom molecular datasets:
pythonimport deepchem as dc # 1. Load and featurize data featurizer = dc.feat.CircularFingerprint(radius=2, size=2048) loader = dc.data.CSVLoader( tasks=['activity'], feature_field='smiles', featurizer=featurizer ) dataset = loader.create_dataset('my_molecules.csv') # 2. Split data (use ScaffoldSplitter for molecules!) splitter = dc.splits.ScaffoldSplitter() train, valid, test = splitter.train_valid_test_split(dataset) # 3. Normalize (optional but recommended) transformers = [dc.trans.NormalizationTransformer( transform_y=True, dataset=train )] for transformer in transformers: train = transformer.transform(train) valid = transformer.transform(valid) test = transformer.transform(test) # 4. Train model model = dc.models.MultitaskRegressor( n_tasks=1, n_features=2048, layer_sizes=[1000, 500], dropouts=0.25 ) model.fit(train, nb_epoch=50) # 5. Evaluate metric = dc.metrics.Metric(dc.metrics.r2_score) test_score = model.evaluate(test, [metric])
For leveraging pretrained models:
pythonimport deepchem as dc # 1. Load data (pretrained models often need raw SMILES) loader = dc.data.CSVLoader( tasks=['activity'], feature_field='smiles', featurizer=dc.feat.DummyFeaturizer() # Model handles featurization ) dataset = loader.create_dataset('small_dataset.csv') # 2. Split data splitter = dc.splits.ScaffoldSplitter() train, test = splitter.train_test_split(dataset) # 3. Load pretrained model model = dc.models.HuggingFaceModel( model='seyonec/ChemBERTa-zinc-base-v1', task='classification', n_tasks=1, learning_rate=2e-5 ) # 4. Fine-tune model.fit(train, nb_epoch=10) # 5. Evaluate predictions = model.predict(test)
See references/workflows.md for 8 detailed workflow examples covering molecular generation, materials science, protein analysis, and more.
This skill includes three production-ready scripts in the scripts/ directory:
predict_solubility.pyTrain and evaluate solubility prediction models. Works with Delaney benchmark or custom CSV data.
bash# Use Delaney benchmark python scripts/predict_solubility.py # Use custom data python scripts/predict_solubility.py \ --data my_data.csv \ --smiles-col smiles \ --target-col solubility \ --predict "CCO" "c1ccccc1"
graph_neural_network.pyTrain various graph neural network architectures on molecular data.
bash# Train GCN on Tox21 python scripts/graph_neural_network.py --model gcn --dataset tox21 # Train AttentiveFP on custom data python scripts/graph_neural_network.py \ --model attentivefp \ --data molecules.csv \ --task-type regression \ --targets activity \ --epochs 100
transfer_learning.pyFine-tune pretrained models (ChemBERTa, GROVER) on molecular property prediction tasks.
bash# Fine-tune ChemBERTa on BBBP python scripts/transfer_learning.py --model chemberta --dataset bbbp # Fine-tune GROVER on custom data python scripts/transfer_learning.py \ --model grover \ --data small_dataset.csv \ --target activity \ --task-type classification \ --epochs 20
python# GOOD: Prevents data leakage splitter = dc.splits.ScaffoldSplitter() train, test = splitter.train_test_split(dataset) # BAD: Similar molecules in train and test splitter = dc.splits.RandomSplitter() train, test = splitter.train_test_split(dataset)
pythontransformers = [ dc.trans.NormalizationTransformer( transform_y=True, # Also normalize target values dataset=train ) ] for transformer in transformers: train = transformer.transform(train) test = transformer.transform(test)
python# Option 1: Balancing transformer transformer = dc.trans.BalancingTransformer(dataset=train) train = transformer.transform(train) # Option 2: Use balanced metrics metric = dc.metrics.Metric(dc.metrics.balanced_accuracy_score)
python# Use DiskDataset for large datasets dataset = dc.data.DiskDataset.from_numpy(X, y, w, ids) # Use smaller batch sizes model = dc.models.GCNModel(batch_size=32) # Instead of 128
Problem: Using random splitting allows similar molecules in train/test sets. Solution: Always use ScaffoldSplitter for molecular datasets.
Problem: Graph neural networks perform worse than simple fingerprints. Solutions:
Problem: Model memorizes training data. Solutions:
Problem: Module not found errors. Solution: Ensure DeepChem is installed with required dependencies:
bashuv pip install deepchem # For PyTorch models uv pip install deepchem[torch] # For all features uv pip install deepchem[all]
This skill includes comprehensive reference documentation:
references/api_reference.mdComplete API documentation including:
When to reference: Search this file when you need specific API details, parameter names, or want to explore available options.
references/workflows.mdEight detailed end-to-end workflows:
When to reference: Use these workflows as templates for implementing complete solutions.
Basic installation:
bashuv pip install deepchem
For PyTorch models (GCN, GAT, etc.):
bashuv pip install deepchem[torch]
For all features:
bashuv pip install deepchem[all]
If import errors occur, the user may need specific dependencies. Check the DeepChem documentation for detailed installation instructions.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-24 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +29 percentage points is the difference between those two pass rates over the 24 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.