logging.info("Model saved in %s", MODEL_PATH) else : logging.info("Loading existing model from %s...",MODEL_PATH) model = load_model(MODEL_PATH) logging.info("Completed loading model from file") logging.info("Predicting on test set...") output = model.predict(x=test_x, verbose=1) logging.debug("Shape of output array: %s",np.shape(output)) obtained_tokens = postprocessing.undo_sequential(output) obtained_words = postprocessing.get_words(test_doc,obtained_tokens) precision = metrics.precision(test_answer,obtained_words) recall = metrics.recall(test_answer,obtained_words) f1 = metrics.f1(precision,recall) print("### Obtained Scores ###") print("### (full dataset) ###") print("###") print("### Precision : %.4f" % precision) print("### Recall : %.4f" % recall) print("### F1 : %.4f" % f1) print("### ###") keras_precision = keras_metrics.keras_precision(test_y,output) keras_recall = keras_metrics.keras_recall(test_y,output) keras_f1 = keras_metrics.keras_f1(test_y,output)
model.save(MODEL_PATH) logging.info("Model saved in %s", MODEL_PATH) else: logging.info("Loading existing model from %s...", MODEL_PATH) model = load_model(MODEL_PATH) logging.info("Completed loading model from file") logging.info("Predicting on test set...") output = model.predict(x=test_x, verbose=1) logging.debug("Shape of output array: %s", np.shape(output)) obtained_tokens = postprocessing.undo_sequential(output) obtained_words = postprocessing.get_words(test_doc, obtained_tokens) precision = metrics.precision(test_answer, obtained_words, STEM_MODE) recall = metrics.recall(test_answer, obtained_words, STEM_MODE) f1 = metrics.f1(precision, recall) print("### Obtained Scores ###") print("### (full dataset) ###") print("###") print("### Precision : %.4f" % precision) print("### Recall : %.4f" % recall) print("### F1 : %.4f" % f1) print("### ###") keras_precision = keras_metrics.keras_precision(test_y, output) keras_recall = keras_metrics.keras_recall(test_y, output) keras_f1 = keras_metrics.keras_f1(test_y, output)