Ejemplo n.º 1
0
                        config.num_steps,
                        shuffle=False):
                    data_feed = {
                        inputs: batch_X,
                        targets: batch_Y,
                        learning_rate: 1.0,
                        keep_prob: 1.0
                    }
                    predict = sess.run([prediction], data_feed)
                    predict = predict[0]
                    final_predict = np.append(final_predict, predict)
                final_predict = np.array(final_predict).reshape(
                    len(final_predict), 1)
                print("0.5 threshold")
                classified = [utils.get_class(x, 0.5) for x in final_predict]
                f, _ = utils.get_score_and_confusion_matrix(labels, classified)
                print("Best threshold")
                best_threshold = utils.find_best_threshold(
                    labels, final_predict)
                best_classified = [
                    utils.get_class(x, best_threshold) for x in final_predict
                ]
                best_f, _ = utils.get_score_and_confusion_matrix(
                    labels, best_classified)

                if which_data == "training":
                    train_score.append(round(sp.average(best_f) * 100, 2))
                else:
                    validation_score.append(round(sp.average(best_f) * 100, 2))

                classified = [
Ejemplo n.º 2
0
                        config.batch_size,
                        config.num_steps,
                        shuffle=False):
                    data_feed = {inputs: batch_X, keep_prob: 1.0}
                    predict = sess.run([prediction], data_feed)
                    predict = predict[0]
                    final_predict = np.append(final_predict, predict)
                final_predict = np.array(final_predict).reshape(
                    len(final_predict), 1)
                # print("0.5 threshold")
                # classified = [utils.get_class(x, 0.5) for x in final_predict]
                # f, _ = utils.get_score_and_confusion_matrix(labels, classified)
                # print("Best threshold")
                # best_threshold = utils.find_best_threshold(labels, final_predict)
                # best_classified = [utils.get_class(x, best_threshold) for x in final_predict]
                best_f, _ = utils.get_score_and_confusion_matrix(
                    labels, final_predict)

                if which_data == "training":
                    train_score.append(round(sp.average(best_f) * 100, 2))
                else:
                    validation_score.append(round(sp.average(best_f) * 100, 2))

                # classified = [utils.get_class(x, best_threshold) for x in final_predict]
                # # Check in all the cases we correctly predict label is explosive 1, how many have the current labels 1
                # current_check = []
                # current_labels = reader.current_labels.values
                # for index, value in enumerate(classified):
                #     if value + labels[index] == 2:  # correctly recognition 1
                #         current = current_labels[index]
                #         if current >= 1:
                #             current_check.append(1)