# Deepchem > ML molecular con featurizers diversos y datasets preconstruidos. Para predicción de propiedades (ADMET, toxicidad) con ML tradicional o GNN. Para PyTorch graph-first usa torchdrug; para datasets de benchmark usa pytdc. Fuente: https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/deepchem Markdown: https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/deepchem.md Repositorio: https://github.com/K-Dense-AI/scientific-agent-skills Autor: K-Dense-AI Licencia: MIT license Actualizado: el mes pasado Coste de contexto: 95 tok instalada, 2.4k tok al activarse, 18.9k tok con todos los archivos del bundle Bundle: 8 archivos, 74 KB Permisos que pide: read write edit bash ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent claude-code # Cursor npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent cursor # Codex npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent codex # Gemini CLI npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent gemini # Windsurf npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent windsurf # Cline npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchem --agent cline ``` ## Qué hace - Aplica machine learning a moléculas con featurizers diversos y datasets de MoleculeNet ya preparados - Predice propiedades moleculares (ADMET, toxicidad) con ML tradicional o redes de grafos (GCN, GAT, MPNN, AttentiveFP) - Aplica transfer learning con modelos preentrenados (ChemBERTa, GROVER, MolFormer) - Da splitters correctos para moléculas (scaffold, butina) para evitar fuga de datos entre train/test ## Cuándo usarla - Se cargan y procesan datos moleculares (SMILES, SDF, secuencias de proteína) - Se predicen propiedades moleculares como solubilidad, toxicidad o afinidad de unión - Se entrena un modelo sobre un dataset de MoleculeNet (Tox21, BBBP, Delaney, etc.) - Se necesita transfer learning con modelos preentrenados para un dataset pequeño ## Cuándo no - Se prefiere un workflow graph-first en PyTorch puro (usar torchdrug) o solo datasets de benchmark (usar pytdc) ## Qué la activa - "Entrena un modelo de solubilidad con DeepChem sobre el benchmark Delaney" - "Entrena una GCN sobre el dataset Tox21" - "Haz fine-tuning de ChemBERTa sobre BBBP" - "Predice la toxicidad de estas moléculas con DeepChem" ## Antes de instalar - Requiere Python 3.7–3.11 y `uv pip install deepchem`; hay que instalar PyTorch, TensorFlow o JAX antes del extra de DeepChem correspondiente (`deepchem[torch]`, etc.). - Necesita en el PATH: python ## Archivos - SKILL.md — 10 KB - references/api_reference.md — 12 KB - references/core_capabilities.md — 8 KB - references/typical_workflows.md — 3 KB - references/workflows.md — 12 KB - scripts/graph_neural_network.py — 10 KB - scripts/predict_solubility.py — 7 KB - scripts/transfer_learning.py — 13 KB ## SKILL.md Reproducido tal cual desde K-Dense-AI/scientific-agent-skills bajo MIT license. Esta sección es el documento original y está en inglés. # DeepChem ## Overview 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. ## When to Use This Skill This skill should be used when: - Loading and processing molecular data (SMILES strings, SDF files, protein sequences) - Predicting molecular properties (solubility, toxicity, binding affinity, ADMET properties) - Training models on chemical/biological datasets - Using MoleculeNet benchmark datasets (Tox21, BBBP, Delaney, etc.) - Converting molecules to ML-ready features (fingerprints, graph representations, descriptors) - Implementing graph neural networks for molecules (GCN, GAT, MPNN, AttentiveFP) - Applying transfer learning with pretrained models (ChemBERTa, GROVER, MolFormer) - Predicting crystal/materials properties (bandgap, formation energy) - Analyzing protein or DNA sequences ## Core Capabilities Eight capability areas, each with worked code, are in [references/core_capabilities.md](references/core_capabilities.md): 1. **Molecular data loading and processing** — loaders, `NumpyDataset` / `DiskDataset`. 2. **Molecular featurization** — circular fingerprints, graph convolution, and descriptors. 3. **Data splitting** — random, scaffold, stratified, and butina splitters, and why scaffold splitting is the honest default for molecules. 4. **Model selection and training** — the model families and how to fit them. 5. **MoleculeNet benchmarks** — loading standard datasets and their published splits. 6. **Transfer learning** — pretraining and fine-tuning. 7. **Model evaluation** — metrics appropriate to regression and classification tasks. 8. **Making predictions** — applying a trained model to new molecules. Three end-to-end workflows are in [references/typical_workflows.md](references/typical_workflows.md). ## Example Scripts This skill includes three production-ready scripts in the `scripts/` directory: ### 1. `predict_solubility.py` Train 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" ``` ### 2. `graph_neural_network.py` Train 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 ``` ### 3. `transfer_learning.py` Fine-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 ``` ## Common Patterns and Best Practices ### Pattern 1: Always Use Scaffold Splitting for Molecules ```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) ``` ### Pattern 2: Normalize Features and Targets ```python transformers = [ dc.trans.NormalizationTransformer( transform_y=True, # Also normalize target values dataset=train ) ] for transformer in transformers: train = transformer.transform(train) test = transformer.transform(test) ``` ### Pattern 3: Start Simple, Then Scale 1. Start with Random Forest + CircularFingerprint (fast baseline) 2. Try XGBoost/LightGBM if RF works well 3. Move to deep learning (MultitaskRegressor) if you have >5K samples 4. Try GNNs if you have >10K samples 5. Use transfer learning for small datasets or novel scaffolds ### Pattern 4: Handle Imbalanced Data ```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) ``` ### Pattern 5: Avoid Memory Issues ```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 ``` ## Common Pitfalls ### Issue 1: Data Leakage in Drug Discovery **Problem**: Using random splitting allows similar molecules in train/test sets. **Solution**: Always use `ScaffoldSplitter` for molecular datasets. ### Issue 2: GNN Underperforming vs Fingerprints **Problem**: Graph neural networks perform worse than simple fingerprints. **Solutions**: - Ensure dataset is large enough (>10K samples typically) - Increase training epochs (50-100) - Try different architectures (AttentiveFP, DMPNN instead of GCN) - Use pretrained models (GROVER) ### Issue 3: Overfitting on Small Datasets **Problem**: Model memorizes training data. **Solutions**: - Use stronger regularization (increase dropout to 0.5) - Use simpler models (Random Forest instead of deep learning) - Apply transfer learning (ChemBERTa, GROVER) - Collect more data ### Issue 4: Import Errors **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: ```bash uv 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. ## Reference Documentation This skill includes comprehensive reference documentation: ### `references/api_reference.md` Complete API documentation including: - All data loaders and their use cases - Dataset classes and when to use each - Complete featurizer catalog with selection guide - Model catalog organized by category (50+ models) - MoleculeNet dataset descriptions - Metrics and evaluation functions - Common code patterns **When to reference**: Search this file when you need specific API details, parameter names, or want to explore available options. ### `references/workflows.md` Eight detailed end-to-end workflows: 1. Molecular property prediction from SMILES 2. Using MoleculeNet benchmarks 3. Hyperparameter optimization 4. Transfer learning with pretrained models 5. Molecular generation with GANs 6. Materials property prediction 7. Protein sequence analysis 8. Custom model integration **When to reference**: Use these workflows as templates for implementing complete solutions. ## Installation Core package (data loaders, featurizers, MoleculeNet, scikit-learn wrappers): ```bash uv pip install deepchem ``` Add the extra that matches your model backend (install PyTorch/TensorFlow/JAX first for GPU builds): ```bash uv 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](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. ## Additional Resources - Official documentation: https://deepchem.readthedocs.io/ - GitHub repository: https://github.com/deepchem/deepchem - Tutorials: https://deepchem.readthedocs.io/en/latest/get_started/tutorials.html - Paper: "MoleculeNet: A Benchmark for Molecular Machine Learning" ## Dónde encaja - Categoría: [Datos y analítica](https://skillsagentes.com/categorias/datos-analitica.md) — Consulta, limpia y visualiza datos sin salir del agente. - Creador: [K-Dense-AI](https://skillsagentes.com/creators/k-dense-ai.md) — 163 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Citation Management](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/citation-management.md): Gestión integral de citas académicas: busca en OpenAlex, PubMed y Google Scholar, extrae metadatos precisos, valida citas y genera entradas BibTeX correctamente formateadas. - [Scientific Slides](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/scientific-slides.md): Crea decks de diapositivas y presentaciones para charlas de investigación: PowerPoint, presentaciones de conferencia, seminarios, defensas de tesis. Da estructura, plantillas, guía de tiempos y validación visual. - [Literature Review](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/literature-review.md): Realiza revisiones bibliográficas sistemáticas y completas usando varias bases académicas (PubMed, arXiv, bioRxiv, Semantic Scholar). Genera markdown y PDF con citas verificadas en varios estilos (APA, Nature, Vancouver). - [Infographics](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/infographics.md): Crea infografías profesionales con Nano Banana Pro AI y refinamiento iterativo inteligente. Usa Gemini 3.6 Flash para revisar la calidad e integra investigación con Perplexity Sonar. Soporta 10 tipos, 8 estilos y paletas para daltonismo. - [Latex Posters](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/latex-posters.md): Crea pósteres de investigación profesionales en LaTeX con beamerposter, tikzposter o baposter, para conferencias y comunicación científica: layout, colores, columnas múltiples e integración de figuras. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)