INNER CODE UNIT · Python
on_epoch_end
drawbridge/keras-mmoe · census_income_demo.py:55
def on_epoch_end(self, epoch, logs={}):
train_prediction = self.model.predict(self.train_X)
validation_prediction = self.model.predict(self.validation_X)
test_prediction = self.model.predict(self.test_X)
# Iterate through each task and output their ROC-AUC across different datasets
for index, output_name in enumerate(self.model.output_names):
train_roc_auc = roc_auc_score(self.train_Y[index], train_prediction[index])
validation_roc_auc = roc_auc_score(self.validation_Y[index], validation_prediction[index])
test_roc_auc = roc_auc_score(self.test_Y[index], test_prediction[index])
print(
'ROC-AUC-{}-Train: {} ROC-AUC-{}-Validation: {} ROC-AUC-{}-Test: {}'.format(
output_name, round(train_roc_auc, 4),
output_name, round(validation_roc_auc, 4),
output_name, round(test_roc_auc, 4)
)
)