Commit f7a42ba0 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Cleaning up

parent b3463f05
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -579,6 +579,14 @@ class Metric(object):

      metric_value = self.compute_singletask_metric(y_task, y_pred_task, w_task)
      computed_metrics.append(metric_value)
    ##################
    print("y_true.shape")
    print(y_true.shape)
    print("y_pred.shape")
    print(y_pred.shape)
    print("computed_metrics")
    print(computed_metrics)
    ##################
    logger.info("computed_metrics: %s" % str(computed_metrics))
    if n_tasks == 1:
      computed_metrics = computed_metrics[0]
+2 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ def threshold_predictions(y, threshold=0.5):
  threshold: float, optional (Default 0.5)
    The threshold probability for the positive class.

  TODO: This needs to be generalized to multiclass probabilities

  Returns
  -------
  y_out: np.ndarray
+11 −1
Original line number Diff line number Diff line
@@ -15,6 +15,13 @@ class TestEvaluator(unittest.TestCase):
    self.dataset = dc.data.NumpyDataset(X, y)
    self.model = dc.models.MultitaskRegressor(1, 5)

  def threshold_predictions(self):
    """Check prediction thresholding works correctly."""
    # TODO: Finish this test
    y = np.random.rand(10, 5)
    y_sums = np.sum(y, axis=1)
    y = y / y_sums

  def test_evaluator_dc_metric(self):
    """Test an evaluator on a dataset."""
    evaluator = Evaluator(self.model, self.dataset, [])
@@ -101,8 +108,11 @@ class TestEvaluator(unittest.TestCase):
    dataset = dc.data.NumpyDataset(X, y)
    model = dc.models.MultitaskClassifier(1, 5, n_classes=5)
    evaluator = Evaluator(model, dataset, [])
    # TODO: Fix this case with correct thresholding
    #multitask_scores = evaluator.compute_model_performance(
    #  sklearn.metrics.accuracy_score, n_classes=5)
    multitask_scores = evaluator.compute_model_performance(
      sklearn.metrics.accuracy_score, n_classes=5)
      sklearn.metrics.roc_auc_score, n_classes=5)
    assert len(multitask_scores) == 1
    assert multitask_scores["metric-1"] >= 0