Skip to content

Commit

Permalink
More fixes to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
peastman committed Aug 26, 2019
1 parent 1636ede commit e3ca5d6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/muv/muv_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
metric = dc.metrics.Metric(
dc.metrics.roc_auc_score, np.mean, mode="classification")

rate = dc.models.tensorgraph.optimizers.ExponentialDecay(0.001, 0.8, 1000)
rate = dc.models.optimizers.ExponentialDecay(0.001, 0.8, 1000)
model = dc.models.MultitaskClassifier(
len(muv_tasks),
n_features=1024,
Expand Down
15 changes: 3 additions & 12 deletions examples/nci/nci_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import numpy as np
import shutil
from nci_datasets import load_nci
from deepchem.molnet import load_nci
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestRegressor
from deepchem.data import Dataset
Expand All @@ -23,28 +23,19 @@
# Set some global variables up top
verbosity = "high"

base_dir = "/tmp/nci_rf"
model_dir = os.path.join(base_dir, "model")
if os.path.exists(base_dir):
shutil.rmtree(base_dir)
os.makedirs(base_dir)

nci_tasks, nci_dataset, transformers = load_nci(
base_dir)
nci_tasks, nci_dataset, transformers = load_nci()

(train_dataset, valid_dataset, test_dataset) = nci_dataset

classification_metric = Metric(metrics.roc_auc_score, np.mean,
verbosity=verbosity,
mode="classification")
def model_builder(model_dir):
sklearn_model = RandomForestRegressor(n_estimators=500)
return SklearnModel(sklearn_model, model_dir)
model = SingletaskToMultitask(nci_tasks, model_builder, model_dir)
model = SingletaskToMultitask(nci_tasks, model_builder)

# Fit trained model
model.fit(train_dataset)
model.save()

train_evaluator = Evaluator(model, train_dataset, transformers, verbosity=verbosity)
train_scores = train_evaluator.compute_model_performance([classification_metric])
Expand Down
1 change: 0 additions & 1 deletion examples/pcba/pcba_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

# Fit trained model
model.fit(train_dataset)
model.save()

train_evaluator = Evaluator(model, train_dataset, transformers)
train_scores = train_evaluator.compute_model_performance([metric])
Expand Down
3 changes: 1 addition & 2 deletions examples/pdbbind/pdbbind_atomic_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
frag1_num_atoms = 70 # for ligand atoms
frag2_num_atoms = 24000 # for protein atoms
complex_num_atoms = frag1_num_atoms + frag2_num_atoms
atomic_convnet = atomic_conv.AtomicConvModel(
batch_size=batch_size,
model = dc.models.AtomicConvModel(
frag1_num_atoms=frag1_num_atoms,
frag2_num_atoms=frag2_num_atoms,
complex_num_atoms=complex_num_atoms)
Expand Down
7 changes: 2 additions & 5 deletions examples/pdbbind/pdbbind_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@

metric = dc.metrics.Metric(dc.metrics.pearson_r2_score)

current_dir = os.path.dirname(os.path.realpath(__file__))
model_dir = os.path.join(current_dir, "%s_%s_RF" % (split, subset))

sklearn_model = RandomForestRegressor(n_estimators=500)
model = dc.models.SklearnModel(sklearn_model, model_dir=model_dir)
model = dc.models.SklearnModel(sklearn_model)

# Fit trained model
print("Fitting model on train dataset")
model.fit(train_dataset)
model.save()

print("Evaluating model")
train_scores = model.evaluate(train_dataset, [metric], transformers)
Expand All @@ -44,3 +40,4 @@

print("Validation scores")
print(valid_scores)

1 change: 0 additions & 1 deletion examples/pdbbind/pdbbind_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

# Fit trained model
model.fit(train_dataset, nb_epoch=100)
model.save()

print("Evaluating model")
train_scores = model.evaluate(train_dataset, [metric], transformers)
Expand Down

0 comments on commit e3ca5d6

Please sign in to comment.