fix mongo observer
All checks were successful
s444452-training/pipeline/head This commit looks good
s444452-evaluation/pipeline/head This commit looks good

This commit is contained in:
AdamOsiowy123 2022-05-09 08:44:44 +02:00
parent 411ec3db86
commit a4b75a3821

View File

@ -46,15 +46,17 @@ def tokenize(x, x_test, pad_length, num_words):
@ex.capture
def evaluate_and_save(model, x, y, abs_path, build_number):
def evaluate_and_save(model, x, y, abs_path, build_number, _run):
loss, accuracy = model.evaluate(x, y, verbose=False)
y_predicted = (model.predict(x) >= 0.5).astype(int)
evaluation_file_path = os.path.join(abs_path, 'neural_network_evaluation.csv')
with open(evaluation_file_path, 'a+') as f:
result = f'{build_number},{accuracy},{loss},{precision_score(y, y_predicted)},{recall_score(y, y_predicted)},{f1_score(y, y_predicted)}'
f.write(result + '\n')
ex.log_scalar("loss", loss)
ex.log_scalar("accuracy", accuracy)
# ex.log_scalar("loss", loss)
_run.log_scalar("loss", loss)
# ex.log_scalar("accuracy", accuracy)
_run.log_scalar("accuracy", accuracy)
ex.add_artifact(evaluation_file_path)