Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Molecular ML with diverse featurizers and pre-built datasets. Use for property prediction (ADMET, toxicity) with traditional ML or GNNs when you want extensive featurization options and MoleculeNet benchmarks. Best for quick experiments with pre-trained models, diverse molecular representations. For graph-first PyTorch workflows use torchdrug; for benchmark datasets use pytdc.
.claude/skills/lingxling-deepchem/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 160% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 233% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 414% | 0% |
| case-23 | ✓→✗ | ▼ Worse | 141% | 0% |
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.
Version note: Examples target deepchem 2.8.0 (PyPI stable, Apr 2024). Requires Python 3.7–3.11 (<3.12 on PyPI). Core utilities (loaders, featurizers, MoleculeNet) work without a DL backend; GNN and transformer models need the matching extra (torch, tensorflow, or jax). Install the backend framework first when using GPU builds.
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, MolFormer) 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: No module named 'torch' / No module named 'tensorflow' warnings, or model classes fail to import. Solution: DeepChem loads lazily — install the backend that matches your model, then add the matching extra:
bashuv pip install deepchem # loaders, featurizers, MoleculeNet only uv pip install 'deepchem[torch]' # GCN, GAT, AttentiveFP, HuggingFaceModel, GroverModel uv pip install 'deepchem[tensorflow]' # legacy Keras models uv pip install 'deepchem[jax]' # Haiku/JAX models
Install PyTorch or TensorFlow with the correct CUDA build before the extra when using GPUs. Quote extras in zsh: 'deepchem[torch]'.
Conda + PyTorch users: If import deepchem fails with undefined symbol: iJIT_NotifyEvent, pin MKL below 2025 (conda install "mkl<2025") — PyTorch wheels may be incompatible with MKL 2025.0.0.
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.
Core package (data loaders, featurizers, MoleculeNet, scikit-learn wrappers):
bashuv pip install deepchem
Add the extra that matches your model backend (install PyTorch/TensorFlow/JAX first for GPU builds):
bashuv pip install 'deepchem[torch]' # GNNs, TorchModel, HuggingFaceModel, GroverModel uv pip install 'deepchem[tensorflow]' # Keras/TensorFlow models uv pip install 'deepchem[jax]' # JAX/Haiku models uv pip install 'deepchem[dqc]' # Differentiable quantum chemistry (torch + xitorch)
Nightly builds: uv pip install --pre deepchem (same extras apply with --pre).
See installation guide and soft requirements for optional dependencies per model class.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-09 | fail→pass | 17,382 | 13,507 | -22% | 1 | 1 | 0% | 2,988 | 7,781 | +160% | 0 | 0 | — |
case-01 | fail→pass | 104,714 | 23,320 | -78% | 1 | 1 | 0% | 6,361 | 8,743 | +37% | 0 | 0 | — |
case-02 | pass→pass | 16,932 | 9,455 | -44% | 1 | 1 | 0% | 2,251 | 6,812 | +203% | 0 | 0 | — |
case-03 | pass→pass | 13,700 | 9,741 | -29% | 1 | 1 | 0% | 2,150 | 6,626 | +208% | 0 | 0 | — |
case-04 | fail→pass | 14,001 | 8,971 | -36% | 1 | 1 | 0% | 1,968 | 6,554 | +233% | 0 | 0 | — |
case-05 | pass→pass | 9,962 | 8,483 | -15% | 1 | 1 | 0% | 1,754 | 6,437 | +267% | 0 | 0 | — |
case-06 | pass→pass | 16,296 | 11,481 | -30% | 1 | 1 | 0% | 2,468 | 7,353 | +198% | 0 | 0 | — |
case-07 | pass→pass | 7,683 | 5,808 | -24% | 1 | 1 | 0% | 1,417 | 6,285 | +344% | 0 | 0 | — |
case-08 | pass→pass | 10,182 | 10,387 | +2% | 1 | 1 | 0% | 1,450 | 6,992 | +382% | 0 | 0 | — |
case-10 | pass→pass | 8,132 | 8,595 | +6% | 1 | 1 | 0% | 1,271 | 6,680 | +426% | 0 | 0 | — |
case-11 | pass→pass | 7,769 | 5,358 | -31% | 1 | 1 | 0% | 1,351 | 6,077 | +350% | 0 | 0 | — |
case-12 | pass→pass | 7,305 | 4,014 | -45% | 1 | 1 | 0% | 1,200 | 5,893 | +391% | 0 | 0 | — |
case-13 | pass→pass | 7,794 | 10,088 | +29% | 1 | 1 | 0% | 1,336 | 7,019 | +425% | 0 | 0 | — |
case-14 | pass→pass | 17,820 | 12,005 | -33% | 1 | 1 | 0% | 2,456 | 7,333 | +199% | 0 | 0 | — |
case-15 | pass→pass | 13,826 | 10,337 | -25% | 1 | 1 | 0% | 2,055 | 7,140 | +247% | 0 | 0 | — |
case-16 | pass→pass | 15,671 | 14,168 | -10% | 1 | 1 | 0% | 2,660 | 7,971 | +200% | 0 | 0 | — |
case-17 | pass→pass | 12,652 | 6,471 | -49% | 1 | 1 | 0% | 1,961 | 6,221 | +217% | 0 | 0 | — |
case-18 | pass→pass | 12,043 | 10,869 | -10% | 1 | 1 | 0% | 2,113 | 6,739 | +219% | 0 | 0 | — |
case-19 | pass→pass | 8,708 | 5,444 | -37% | 1 | 1 | 0% | 1,503 | 6,210 | +313% | 0 | 0 | — |
case-20 | fail→pass | 8,263 | 4,847 | -41% | 1 | 1 | 0% | 1,206 | 6,197 | +414% | 0 | 0 | — |
case-21 | pass→pass | 24,786 | 15,685 | -37% | 1 | 1 | 0% | 3,821 | 7,791 | +104% | 0 | 0 | — |
case-22 | pass→pass | 25,377 | 26,645 | +5% | 1 | 1 | 0% | 3,994 | 9,333 | +134% | 0 | 0 | — |
case-23 | pass→fail | 16,257 | 17,013 | +5% | 1 | 1 | 0% | 3,594 | 8,645 | +141% | 0 | 0 | — |
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. 23 cases were attempted. The headline lift of +13 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.