示例#1
0
  def test_dag_model(self):
    tasks, dataset, transformers, metric = self.get_dataset(
        'classification', 'GraphConv')

    max_atoms = max([mol.get_num_atoms() for mol in dataset.X])
    transformer = dc.trans.DAGTransformer(max_atoms=max_atoms)
    dataset = transformer.transform(dataset)

    model = DAGModel(
        len(tasks), max_atoms=max_atoms, mode='classification', use_queue=False)

    model.fit(dataset, nb_epoch=10)
    scores = model.evaluate(dataset, [metric], transformers)
    assert scores['mean-roc_auc_score'] >= 0.9

    model.save()
    model = TensorGraph.load_from_dir(model.model_dir)
    scores2 = model.evaluate(dataset, [metric], transformers)
    assert np.allclose(scores['mean-roc_auc_score'],
                       scores2['mean-roc_auc_score'])
示例#2
0
  def test_dag_model(self):
    tasks, dataset, transformers, metric = self.get_dataset(
        'classification', 'GraphConv')

    max_atoms = max([mol.get_num_atoms() for mol in dataset.X])
    transformer = dc.trans.DAGTransformer(max_atoms=max_atoms)
    dataset = transformer.transform(dataset)

    model = DAGModel(
        len(tasks), max_atoms=max_atoms, mode='classification', use_queue=False)

    model.fit(dataset, nb_epoch=10)
    scores = model.evaluate(dataset, [metric], transformers)
    assert scores['mean-roc_auc_score'] >= 0.9

    model.save()
    model = TensorGraph.load_from_dir(model.model_dir)
    scores2 = model.evaluate(dataset, [metric], transformers)
    assert np.allclose(scores['mean-roc_auc_score'],
                       scores2['mean-roc_auc_score'])
示例#3
0
    def test_dag_regression_model(self):
        tasks, dataset, transformers, metric = self.get_dataset(
            'regression', 'GraphConv')

        max_atoms = max([mol.get_num_atoms() for mol in dataset.X])
        transformer = dc.trans.DAGTransformer(max_atoms=max_atoms)
        dataset = transformer.transform(dataset)

        model = DAGModel(len(tasks),
                         max_atoms=max_atoms,
                         mode='regression',
                         learning_rate=0.003,
                         use_queue=False)

        model.fit(dataset, nb_epoch=100)
        scores = model.evaluate(dataset, [metric], transformers)
        assert all(s < 0.15 for s in scores['mean_absolute_error'])

        model.save()
        model = TensorGraph.load_from_dir(model.model_dir)
        scores2 = model.evaluate(dataset, [metric], transformers)
        assert np.allclose(scores['mean_absolute_error'],
                           scores2['mean_absolute_error'])
示例#4
0
  def test_dag_regression_model(self):
    tasks, dataset, transformers, metric = self.get_dataset(
        'regression', 'GraphConv')

    max_atoms = max([mol.get_num_atoms() for mol in dataset.X])
    transformer = dc.trans.DAGTransformer(max_atoms=max_atoms)
    dataset = transformer.transform(dataset)

    model = DAGModel(
        len(tasks),
        max_atoms=max_atoms,
        mode='regression',
        learning_rate=0.003,
        use_queue=False)

    model.fit(dataset, nb_epoch=100)
    scores = model.evaluate(dataset, [metric], transformers)
    assert all(s < 0.15 for s in scores['mean_absolute_error'])

    model.save()
    model = TensorGraph.load_from_dir(model.model_dir)
    scores2 = model.evaluate(dataset, [metric], transformers)
    assert np.allclose(scores['mean_absolute_error'],
                       scores2['mean_absolute_error'])
示例#5
0
model = DAGModel(
    n_tasks=n_tasks,
    max_atoms=max_atoms,
    n_atom_feat=n_atom_feat,
    n_graph_feat=n_graph_feat,
    mode="regression",
    batch_size=batch_size,
    learning_rate=1e-3,
    use_queue=False,
    model_dir="/home/rod/Dropbox/Quimica/Analysis/ANalisis/Borradores/DAGModel/"
)  #To prevent overfitting

# Fit trained model
print("Fitting model")
model.fit(train_dataset, nb_epoch=nb_epoch)
model.save()
print("Evaluating model")
train_scores = model.evaluate(train_dataset, [metric])
valid_scores = model.evaluate(valid_dataset, [metric])

print("Train scores")
print(train_scores)

print("Validation scores")
print(valid_scores)
"""
#Check model predictions
from rdkit import Chem
smiles = ['COC(C)(C)CCCC(C)CC=CC(C)=CC(=O)OC(C)C',
          'CCOC(=O)CC',
          'CSc1nc(NC(C)C)nc(NC(C)C)n1',