Commit 84973fb6 authored by Zheng Xu's avatar Zheng Xu
Browse files

Make featurizer positional.

parent 570a3be6
Loading
Loading
Loading
Loading
+25 −34
Original line number Diff line number Diff line
@@ -219,9 +219,7 @@ def run_benchmark(datasets,
#   2+. The cache can even happen at Travis CI to accelerate
#       CI testing.
#
def load_dataset(dataset,
                 split=None,
                 featurizer=None):
def load_dataset(dataset, featurizer, split=None):
  """
  Load specific dataset for benchmark.
  
@@ -231,11 +229,10 @@ def load_dataset(dataset,
      choice of which datasets to use, should be: tox21, muv, sider, 
      toxcast, pcba, delaney, kaggle, nci, clintox, hiv, pdbbind, chembl,
      qm7, qm7b, qm9, sampl
  featurizer: string or dc.feat.Featurizer.
      choice of featurization.
  split: string,  optional (default=None)
      choice of splitter function, None = using the default splitter
  featurizer: string or dc.feat.Featurizer,  optional (default=None)
      choice of featurization, None = using the default corresponding to model
      (string only applicable to deepchem models)
  """
  dataset_loading_functions = {
      'tox21': deepchem.molnet.load_tox21,
@@ -265,11 +262,8 @@ def load_dataset(dataset,
      featurizer=featurizer, split=split)
  return tasks, all_dataset, transformers

def benchmark_model(model,
                    all_dataset,
                    transformers,
                    metric,
                    test=False):

def benchmark_model(model, all_dataset, transformers, metric, test=False):
  """
  Benchmark custom model.

@@ -294,13 +288,10 @@ def benchmark_model(model,
  train_dataset, valid_dataset, test_dataset = all_dataset

  model.fit(train_dataset)
  train_score = model.evaluate(train_dataset, metric,
                               transformers)
  valid_score = model.evaluate(valid_dataset, metric,
                               transformers)
  train_score = model.evaluate(train_dataset, metric, transformers)
  valid_score = model.evaluate(valid_dataset, metric, transformers)
  if test:
    test_score = model.evaluate(test_dataset, metric,
                                transformers)
    test_score = model.evaluate(test_dataset, metric, transformers)

  time_finish_fitting = time.time()
  time_for_running = time_finish_fitting - time_start_fitting