{"id":"deepchem","name":"deepchem","summary":"多様な特徴と事前構築されたデータセットを持つ分子機械学習。広範な特徴付けオプションやMoleculeNetベンチマークを求める場合、従来のMLやGNNで特性予測(ADMET、毒性)を活用しましょう。","body":"# DeepChem\n\n## Overview\n\nDeepChem 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.\n\n**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.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Loading and processing molecular data (SMILES strings, SDF files, protein sequences)\n- Predicting molecular properties (solubility, toxicity, binding affinity, ADMET properties)\n- Training models on chemical/biological datasets\n- Using MoleculeNet benchmark datasets (Tox21, BBBP, Delaney, etc.)\n- Converting molecules to ML-ready features (fingerprints, graph representations, descriptors)\n- Implementing graph neural networks for molecules (GCN, GAT, MPNN, AttentiveFP)\n- Applying transfer learning with pretrained models (ChemBERTa, GROVER, MolFormer)\n- Predicting crystal/materials properties (bandgap, formation energy)\n- Analyzing protein or DNA sequences\n\n## Core Capabilities\n\nEight capability areas, each with worked code, are in\n[references/core_capabilities.md](references/core_capabilities.md):\n\n1. **Molecular data loading and processing** — loaders, `NumpyDataset` / `DiskDataset`.\n2. **Molecular featurization** — circular fingerprints, graph convolution, and descriptors.\n3. **Data splitting** — random, scaffold, stratified, and butina splitters, and why\n   scaffold splitting is the honest default for molecules.\n4. **Model selection and training** — the model families and how to fit them.\n5. **MoleculeNet benchmarks** — loading standard datasets and their published splits.\n6. **Transfer learning** — pretraining and fine-tuning.\n7. **Model evaluation** — metrics appropriate to regression and classification tasks.\n8. **Making predictions** — applying a trained model to new molecules.\n\nThree end-to-end workflows are in\n[references/typical_workflows.md](references/typical_workflows.md).\n\n## Example Scripts\n\nThis skill includes three production-ready scripts in the `scripts/` directory:\n\n### 1. `predict_solubility.py`\nTrain and evaluate solubility prediction models. Works with Delaney benchmark or custom CSV data.\n\n```bash\n# Use Delaney benchmark\npython scripts/predict_solubility.py\n\n# Use custom data\npython scripts/predict_solubility.py \\\n    --data my_data.csv \\\n    --smiles-col smiles \\\n    --target-col solubility \\\n    --predict \"CCO\" \"c1ccccc1\"\n```\n\n### 2. `graph_neural_network.py`\nTrain various graph neural network architectures on molecular data.\n\n```bash\n# Train GCN on Tox21\npython scripts/graph_neural_network.py --model gcn --dataset tox21\n\n# Train AttentiveFP on custom data\npython scripts/graph_neural_network.py \\\n    --model attentivefp \\\n    --data molecules.csv \\\n    --task-type regression \\\n    --targets activity \\\n    --epochs 100\n```\n\n### 3. `transfer_learning.py`\nFine-tune pretrained models (ChemBERTa, GROVER, MolFormer) on molecular property prediction tasks.\n\n```bash\n# Fine-tune ChemBERTa on BBBP\npython scripts/transfer_learning.py --model chemberta --dataset bbbp\n\n# Fine-tune GROVER on custom data\npython scripts/transfer_learning.py \\\n    --model grover \\\n    --data small_dataset.csv \\\n    --target activity \\\n    --task-type classification \\\n    --epochs 20\n```\n\n## Common Patterns and Best Practices\n\n### Pattern 1: Always Use Scaffold Splitting for Molecules\n```python\n# GOOD: Prevents data leakage\nsplitter = dc.splits.ScaffoldSplitter()\ntrain, test = splitter.train_test_split(dataset)\n\n# BAD: Similar molecules in train and test\nsplitter = dc.splits.RandomSplitter()\ntrain, test = splitter.train_test_split(dataset)\n```\n\n### Pattern 2: Normalize Features and Targets\n```python\ntransformers = [\n    dc.trans.NormalizationTransformer(\n        transform_y=True,  # Also normalize target values\n        dataset=train\n    )\n]\nfor transformer in transformers:\n    train = transformer.transform(train)\n    test = transformer.transform(test)\n```\n\n### Pattern 3: Start Simple, Then Scale\n1. Start with Random Forest + CircularFingerprint (fast baseline)\n2. Try XGBoost/LightGBM if RF works well\n3. Move to deep learning (MultitaskRegressor) if you have >5K samples\n4. Try GNNs if you have >10K samples\n5. Use transfer learning for small datasets or novel scaffolds\n\n### Pattern 4: Handle Imbalanced Data\n```python\n# Option 1: Balancing transformer\ntransformer = dc.trans.BalancingTransformer(dataset=train)\ntrain = transformer.transform(train)\n\n# Option 2: Use balanced metrics\nmetric = dc.metrics.Metric(dc.metrics.balanced_accuracy_score)\n```\n\n### Pattern 5: Avoid Memory Issues\n```python\n# Use DiskDataset for large datasets\ndataset = dc.data.DiskDataset.from_numpy(X, y, w, ids)\n\n# Use smaller batch sizes\nmodel = dc.models.GCNModel(batch_size=32)  # Instead of 128\n```\n\n## Common Pitfalls\n\n### Issue 1: Data Leakage in Drug Discovery\n**Problem**: Using random splitting allows similar molecules in train/test sets.\n**Solution**: Always use `ScaffoldSplitter` for molecular datasets.\n\n### Issue 2: GNN Underperforming vs Fingerprints\n**Problem**: Graph neural networks perform worse than simple fingerprints.\n**Solutions**:\n- Ensure dataset is large enough (>10K samples typically)\n- Increase training epochs (50-100)\n- Try different architectures (AttentiveFP, DMPNN instead of GCN)\n- Use pretrained models (GROVER)\n\n### Issue 3: Overfitting on Small Datasets\n**Problem**: Model memorizes training data.\n**Solutions**:\n- Use stronger regularization (increase dropout to 0.5)\n- Use simpler models (Random Forest instead of deep learning)\n- Apply transfer learning (ChemBERTa, GROVER)\n- Collect more data\n\n### Issue 4: Import Errors\n**Problem**: `No module named 'torch'` / `No module named 'tensorflow'` warnings, or model classes fail to import.\n**Solution**: DeepChem loads lazily — install the backend that matches your model, then add the matching extra:\n```bash\nuv pip install deepchem              # loaders, featurizers, MoleculeNet only\nuv pip install 'deepchem[torch]'       # GCN, GAT, AttentiveFP, HuggingFaceModel, GroverModel\nuv pip install 'deepchem[tensorflow]'  # legacy Keras models\nuv pip install 'deepchem[jax]'         # Haiku/JAX models\n```\nInstall PyTorch or TensorFlow with the correct CUDA build **before** the extra when using GPUs. Quote extras in zsh: `'deepchem[torch]'`.\n\n**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.\n\n## Reference Documentation\n\nThis skill includes comprehensive reference documentation:\n\n### `references/api_reference.md`\nComplete API documentation including:\n- All data loaders and their use cases\n- Dataset classes and when to use each\n- Complete featurizer catalog with selection guide\n- Model catalog organized by category (50+ models)\n- MoleculeNet dataset descriptions\n- Metrics and evaluation functions\n- Common code patterns\n\n**When to reference**: Search this file when you need specific API details, parameter names, or want to explore available options.\n\n### `references/workflows.md`\nEight detailed end-to-end workflows:\n1. Molecular property prediction from SMILES\n2. Using MoleculeNet benchmarks\n3. Hyperparameter optimization\n4. Transfer learning with pretrained models\n5. Molecular generation with GANs\n6. Materials property prediction\n7. Protein sequence analysis\n8. Custom model integration\n\n**When to reference**: Use these workflows as templates for implementing complete solutions.\n\n## Installation\n\nCore package (data loaders, featurizers, MoleculeNet, scikit-learn wrappers):\n\n```bash\nuv pip install deepchem\n```\n\nAdd the extra that matches your model backend (install PyTorch/TensorFlow/JAX first for GPU builds):\n\n```bash\nuv pip install 'deepchem[torch]'       # GNNs, TorchModel, HuggingFaceModel, GroverModel\nuv pip install 'deepchem[tensorflow]'  # Keras/TensorFlow models\nuv pip install 'deepchem[jax]'         # JAX/Haiku models\nuv pip install 'deepchem[dqc]'         # Differentiable quantum chemistry (torch + xitorch)\n```\n\nNightly builds: `uv pip install --pre deepchem` (same extras apply with `--pre`).\n\nSee [installation guide](https://deepchem.readthedocs.io/en/latest/get_started/installation.html) and [soft requirements](https://deepchem.readthedocs.io/en/latest/requirements.html) for optional dependencies per model class.\n\n## Additional Resources\n\n- Official documentation: https://deepchem.readthedocs.io/\n- GitHub repository: https://github.com/deepchem/deepchem\n- Tutorials: https://deepchem.readthedocs.io/en/latest/get_started/tutorials.html\n- Paper: \"MoleculeNet: A Benchmark for Molecular Machine Learning\"","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/deepchem","license":"MIT","category":"coding","lang":"en","tokens":2146,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/api_reference.md","size":11822,"sha256":"ba98f4677c200317789b540531f869dc2528d49cd7d08ee3be7592b339c61039"},{"path":"references/core_capabilities.md","size":8514,"sha256":"379800aeaaef7608a595d2ebf5173823fdd4fb2d8ff64306ed2ed705023e82f8"},{"path":"references/typical_workflows.md","size":2713,"sha256":"55200eec4ea79d9a378a9c1dab27bd18318c9895545adc90b595c32e7d43c02a"},{"path":"references/workflows.md","size":12026,"sha256":"668e88323211025a848470ae76d6337c5fdd4fb0e791333eaf8193322e0b522e"},{"path":"scripts/graph_neural_network.py","size":10215,"sha256":"e6643bed6653407696d24d40491c3c8ad00c374f0e3895161d8466b50653ab11"},{"path":"scripts/predict_solubility.py","size":6785,"sha256":"8b0ef83e042521e3d55cfbc882dd86e690def1350b0e35661ae199aa708a5631"},{"path":"scripts/transfer_learning.py","size":13631,"sha256":"aca2b850a91411b12ba6fc6b814a166ca6e27aefdc61a9ec9063a21664bc935a"}],"requires":{"mcp":[],"tools":["Read Write Edit Bash"]},"safety":{"flags":[{"code":"net.endpoints","kind":"exfiltration","excerpt":"deepchem.readthedocs.io","message":"bundled scripts reach 1 external host(s)","severity":"warn"}],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":["deepchem.readthedocs.io"]}}