Commit 864e1d1a authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Cleanup of cruft code

parent 68a9961c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -397,9 +397,6 @@ def _df_to_numpy(df, feature_types, tasks):
  # perform common train/test split across all tasks
  n_samples = df.shape[0]
  n_tasks = len(tasks)
  #y = df[tasks].values
  print("df.keys()")
  print(df.keys())
  y = np.array([df[task].values for task in tasks])
  y = np.reshape(y, (n_samples, n_tasks))
  w = np.ones((n_samples, n_tasks))
+0 −9
Original line number Diff line number Diff line
@@ -248,10 +248,8 @@ class TensorflowGraph(object):
      ValueError: If output and labels are not both 3D or both 2D.
    """
    
    ######### DEBUG
    if not self._restored_model:
      self.restore()
    ######### DEBUG
    with self.graph.as_default():
      assert not model_ops.is_training()
      self.require_attributes(['output'])
@@ -388,15 +386,10 @@ class TensorflowGraph(object):
    if self._restored_model:
      return
    with self.graph.as_default():
      print("RESTORING MODEL FROM CHECKPOINT")
      assert not model_ops.is_training()
      last_checkpoint = self._find_last_checkpoint()
      print("last_checkpoint")
      print(last_checkpoint)

      saver = tf.train.Saver()
      #saver.restore(self._get_shared_session(),
      #              tf_utils.ParseCheckpoint(last_checkpoint))
      saver.restore(self._get_shared_session(),
                    last_checkpoint)
      self._restored_model = True
@@ -574,14 +567,12 @@ class TensorflowModel(Model):
    Makes predictions on batch of data.
    """
    return self.eval_model.predict_on_batch(X)
    #return self.train_model.predict_on_batch(X)

  def predict_proba_on_batch(self, X):
    """
    Makes predictions on batch of data.
    """
    return self.eval_model.predict_proba_on_batch(X)
    #return self.train_model.predict_proba_on_batch(X)

  def save(self):
    """
+1 −10
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ class TensorflowMultiTaskClassifier(TensorflowClassifier):
            bias_init=tf.constant(value=bias_init_consts[i],
                                  shape=[layer_sizes[i]])))
        layer = model_ops.Dropout(layer, dropouts[i])
        #layer = tf.nn.dropout(layer, dropouts[i])
        prev_layer = layer
        prev_layer_size = layer_sizes[i]

@@ -186,14 +185,10 @@ class TensorflowMultiTaskClassifier(TensorflowClassifier):
      AssertionError: If model is not in evaluation mode.
      ValueError: If output and labels are not both 3D or both 2D.
    """
    ######### DEBUG
    if not self._restored_model:
      self.restore()
    ######### DEBUG
    with self.graph.as_default():
      ########## DEBUG
      assert not model_ops.is_training()
      ########## DEBUG
      self.require_attributes(['output'])

      # run eval data through the model
@@ -330,14 +325,10 @@ class TensorflowMultiTaskRegressor(TensorflowRegressor):
      AssertionError: If model is not in evaluation mode.
      ValueError: If output and labels are not both 3D or both 2D.
    """
    ########## DEBUG
    if not self._restored_model:
      self.restore()
    ########## DEBUG
    with self.graph.as_default():
      ########### DEBUG
      #assert not model_ops.is_training()
      ########### DEBUG
      assert not model_ops.is_training()
      self.require_attributes(['output'])

      # run eval data through the model
+0 −18
Original line number Diff line number Diff line
@@ -68,19 +68,6 @@ class Evaluator(object):
      mode = metrics[0].mode
    if mode == "classification":
      y_pred = self.model.predict_proba(self.dataset, self.transformers)
      ############ DEBUG
      ##import sklearn
      ##from deepchem.metrics import to_one_hot
      ##print("compute_model_performance()")
      ##print("y_pred.shape, y.shape")
      ##print(y_pred.shape, y.shape)
      ##print("sklearn.metrics.log_loss(to_one_hot(y), np.squeeze(y_pred))")
      ##print(sklearn.metrics.log_loss(to_one_hot(y), np.squeeze(y_pred)))
      ##print("sklearn.metrics.roc_auc_score(to_one_hot(y), np.squeeze(y_pred))")
      ##print(sklearn.metrics.roc_auc_score(to_one_hot(y), np.squeeze(y_pred)))
      ##print("sklearn.metrics.roc_auc_score(to_one_hot(y), np.squeeze(y_pred), sample_weight=w)")
      ##print(sklearn.metrics.roc_auc_score(to_one_hot(y), np.squeeze(y_pred), sample_weight=w))
      ############ DEBUG
  
    else:
      y_pred = self.model.predict(self.dataset, self.transformers)
@@ -94,9 +81,4 @@ class Evaluator(object):
    for metric in metrics:
      multitask_scores[metric.name] = metric.compute_metric(y, y_pred, w)
  
    ########## DEBUG
    print("multitask_scores")
    print(multitask_scores)
    ########## DEBUG

    return multitask_scores