Skip to content

Commit

Permalink
Bugfix repairing individual ensemble predictions (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmcgill committed May 3, 2022
1 parent 60b80ed commit e0f644c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chemprop/uncertainty/uncertainty_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def calculate_uncertainty(self, calibrator: UncertaintyCalibrator = None):

def individual_predictions(self):
"""
Return separate predictions made by each individual model in an ensemble of models.
"""
return self.predictor.get_individual_ensemble_predictions()
return self.predictor.get_individual_preds()
26 changes: 26 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,32 @@ def test_predict_single_task_regression(self,
pred, true = pred.to_numpy(), true.to_numpy()
mse = float(np.nanmean((pred - true) ** 2))
self.assertAlmostEqual(mse, expected_score, delta=DELTA*expected_score)

def test_predict_individual_ensemble(self):
with TemporaryDirectory() as save_dir:
save_dir = f'../test/pred_single_regression/individual_ensemble'
# Train
dataset_type = 'regression'
self.train(
dataset_type=dataset_type,
metric='rmse',
save_dir=save_dir,
)

# Predict
preds_path = os.path.join(save_dir, 'preds.csv')
self.predict(
dataset_type=dataset_type,
preds_path=preds_path,
save_dir=save_dir,
flags=['--individual_ensemble_predictions']
)

pred = pd.read_csv(preds_path)
columns = list(pred.columns)
expected_columns = ['smiles', 'logSolubility'] + [f'logSolubility_model_{idx}' for idx in range(NUM_FOLDS)]
self.assertTrue(columns == expected_columns)


@parameterized.expand([
(
Expand Down

0 comments on commit e0f644c

Please sign in to comment.