---
title: Data prep & featurization
description: Data preparation and featurization guide for DeepPurpose DTI prediction.
---

[DeepPurpose](https://github.com/kexinhuang12345/DeepPurpose) is a deep learning library for drug-target interaction (DTI) prediction, published in Bioinformatics. This guide covers data preparation for training DTI models.

## Input format

Create a CSV with SMILES, FASTA targets, and labels:

```csv
smiles,protein,affinity
CC(=O)Oc1ccccc1C(=O)O,>sp|P00533|EGFR_HUMAN...SEQUENCE...,8.1
CC1=CC=CC=C1,>sp|P00533|EGFR_HUMAN...SEQUENCE...,6.4
```

## Train/val/test splits

```python
import pandas as pd
from sklearn.model_selection import train_test_split

df = pd.read_csv("inputs/data.csv")
train, temp = train_test_split(df, test_size=0.3, random_state=42)
val, test = train_test_split(temp, test_size=0.5, random_state=42)

train.to_csv("inputs/train.csv", index=False)
val.to_csv("inputs/val.csv", index=False)
test.to_csv("inputs/test.csv", index=False)
```

## Choosing encoders

DeepPurpose provides 15+ compound encoders and 7+ protein encoders that can be combined into 50+ neural architectures.

### Compound (drug) encoders

| Encoder | Type | Description |
|---------|------|-------------|
| `Morgan` | Fingerprint | Morgan/ECFP circular fingerprints |
| `Pubchem` | Fingerprint | PubChem substructure fingerprints |
| `Daylight` | Fingerprint | Daylight-type fingerprints |
| `rdkit_2d_normalized` | Descriptor | RDKit 2D molecular descriptors |
| `CNN` | Deep Learning | 1D CNN on SMILES strings |
| `CNN_RNN` | Deep Learning | CNN + RNN hybrid on SMILES |
| `RNN` | Deep Learning | RNN/LSTM on SMILES sequences |
| `Transformer` | Deep Learning | Transformer encoder on SMILES |
| `MPNN` | GNN | Message Passing Neural Network on molecular graphs |
| `DGL_GCN` | GNN | Graph Convolutional Network (DGL) |
| `DGL_NeuralFP` | GNN | Neural fingerprints via DGL |
| `DGL_AttentiveFP` | GNN | Attentive fingerprints via DGL |
| `DGL_GIN_AttrMasking` | GNN | GIN with attribute masking (pretrained) |
| `DGL_GIN_ContextPred` | GNN | GIN with context prediction (pretrained) |

### Protein (target) encoders

| Encoder | Type | Description |
|---------|------|-------------|
| `AAC` | Descriptor | Amino Acid Composition |
| `PseudoAAC` | Descriptor | Pseudo Amino Acid Composition |
| `Conjoint_triad` | Descriptor | Conjoint triad features |
| `Quasi-seq` | Descriptor | Quasi-sequence order descriptors |
| `CNN` | Deep Learning | 1D CNN on amino acid sequences |
| `CNN_RNN` | Deep Learning | CNN + RNN hybrid |
| `RNN` | Deep Learning | RNN/LSTM on protein sequences |
| `Transformer` | Deep Learning | Transformer encoder on sequences |

### Encoder selection tips

- **Small datasets (&lt;1000 samples)**: Use fingerprint encoders (`Morgan`, `Pubchem`) with descriptor-based protein encoders (`AAC`, `PseudoAAC`)
- **Medium datasets**: CNN-based encoders offer a good balance of performance and speed
- **Large datasets**: Transformer and GNN encoders can capture more complex patterns
- **Pretrained options**: `DGL_GIN_AttrMasking` and `DGL_GIN_ContextPred` leverage pretrained molecular representations

## Featurize with DeepPurpose utils

DeepPurpose provides built-in dataset utilities and benchmark datasets:

```python
from DeepPurpose import dataset

# Load a benchmark dataset (e.g., DAVIS, KIBA, BindingDB)
X_drugs, X_targets, y = dataset.load_process_DAVIS(
    path='./data',
    binary=False,  # Regression task
    convert_to_log=True,
    threshold=30
)

# Or process your own data
X_drug, X_target, y = dataset.data_process(
    X_drug=drug_smiles_list,
    X_target=protein_sequence_list,
    y=affinity_labels,
    drug_encoding="Morgan",
    target_encoding="CNN",
    split_method="random",
    frac=[0.7, 0.1, 0.2],
)
```

### Available benchmark datasets

DeepPurpose includes loaders for common DTI benchmark datasets:

- **DAVIS**: Kinase inhibitor binding affinities (Kd values)
- **KIBA**: Kinase Inhibitor BioActivity dataset
- **BindingDB**: Large-scale binding affinity database
- **DrugBank**: Drug-target associations
- **Tox21**: Toxicity prediction dataset
- **HIV**: HIV replication inhibition dataset

## Data quality tips

- Deduplicate SMILES/targets before splitting.
- Validate FASTA headers and ensure sequences contain only valid amino acids.
- Standardize SMILES (e.g., RDKit canonicalization) before training to reduce
  variance.
- For binding affinity data, consider log transformation (pKd, pKi) for better model convergence.
- Remove invalid SMILES using RDKit's `MolFromSmiles()` validation.

## Split strategies

DeepPurpose supports multiple splitting strategies for robust evaluation:

```python
# Random split (default)
train, val, test = dataset.data_process(..., split_method='random')

# Cold drug split (test on unseen drugs)
train, val, test = dataset.data_process(..., split_method='cold_drug')

# Cold target split (test on unseen proteins)
train, val, test = dataset.data_process(..., split_method='cold_protein')
```

Cold splits are more challenging but better reflect real-world drug discovery scenarios where you predict interactions for novel compounds or targets.
