def test_keras_metric(self): try: from keras.metrics import MeanAbsoluteError Scorer.register_custom_metric(MeanAbsoluteError) Scorer.register_custom_metric('any_weird_metric') except ImportError: pass
def test_doubled_custom_metric(self): def custom_metric(y_true, y_pred): return 99.9 Scorer.register_custom_metric(('a_custom_metric', custom_metric)) with self.assertRaises(Warning): Scorer.register_custom_metric(('a_custom_metric', custom_metric)) with self.assertRaises(ValueError): Scorer.register_custom_metric(None)