In [13]:
import deepchem as dc
from rdkit import Chem

1. Build the Data Set

In [140]:
tasks, datasets, transformers = dc.molnet.load_delaney(featurizer='GraphConv')
train_dataset, valid_dataset, test_dataset = datasets

2. Train the Model

In [141]:
model = dc.models.GraphConvModel(n_tasks=1, mode='regression', dropout=0.2)
model.fit(train_dataset, nb_epoch=100)
Out[141]:
0.11983157157897949

3. Evaluate the Model

In [144]:
metric = dc.metrics.Metric(dc.metrics.pearson_r2_score)

print(model.evaluate(train_dataset, [metric], transformers))
print(model.evaluate(test_dataset, [metric], transformers))
{'pearson_r2_score': 0.9004222705956458}
{'pearson_r2_score': 0.7670473208347418}

4. Use the Model

In [146]:
featurizer = dc.feat.ConvMolFeaturizer()
smiles = ['c1c(O)cccc1O', 'c1c(F)cccc1O', 'c1c(Cl)cccc1O']
x = featurizer.featurize([Chem.MolFromSmiles(s) for s in smiles])

model.predict_on_batch(x)
Out[146]:
array([[2.2862852],
       [1.6334751],
       [1.4213243]], dtype=float32)