kf = KFold(n_splits=FLAGS.folds, random_state=FLAGS.seed) for train_index, test_index in kf.split(filter_commits): X_train_msg, X_test_msg = np.array(get_items(items=pad_msg, indexes=train_index)), \ np.array(get_items(items=pad_msg, indexes=test_index)) X_train_added_code, X_test_added_code = np.array(get_items(items=pad_added_code, indexes=train_index)), \ np.array(get_items(items=pad_added_code, indexes=test_index)) X_train_removed_code, X_test_removed_code = np.array(get_items(items=pad_removed_code, indexes=train_index)), \ np.array(get_items(items=pad_removed_code, indexes=test_index)) y_train, y_test = np.array(get_items(items=labels, indexes=train_index)), \ np.array(get_items(items=labels, indexes=test_index)) return X_test_msg, X_test_added_code, X_test_removed_code, y_test if __name__ == "__main__": tf = model_parameters() FLAGS = tf.flags.FLAGS print_params(tf) if FLAGS.eval_test: X_test_msg, X_test_added_code, X_test_removed_code, y_test = loading_data_lstm(FLAGS=FLAGS) print X_test_msg.shape, X_test_added_code.shape, X_test_removed_code.shape, y_test.shape # X_test_msg, X_test_added_code, X_test_removed_code, y_test = loading_data_all(FLAGS=FLAGS) else: print "You need to turn on the evaluating file." exit() # checkpoint_dir, model = "./runs/fold_0_1521641601/checkpoints", "keras_model" # checkpoint_dir, model = "./runs/fold_0_1522031841/checkpoints", "lstm_all" checkpoint_dir, model = "./runs/fold_0_1522045240/checkpoints", "lstm_code" dirs = get_all_checkpoints(checkpoint_dir=checkpoint_dir)
# path_model = "./keras_model/%s_%s.h5" % (FLAGS.model, str(cntfold)) path_model = "./keras_model/test_%s_%s.h5" % (FLAGS.model, str(cntfold)) # path_model = "./keras_model/%s_%s_testing.h5" % (FLAGS.model, str(cntfold)) model = load_model(path_model) else: print "You need to give correct model name" exit() y_pred = model.predict(X_test_msg, batch_size=FLAGS.batch_size) y_pred = np.ravel(y_pred) pred_dict.update(make_dictionary(y_pred=y_pred, y_index=test_index)) y_pred = y_pred.tolist() pred_dict_list += y_pred # print len(pred_dict_list) # exit() # path_file = "./statistical_test_prob/" + FLAGS.model + ".txt" # write_file(path_file=path_file, data=sorted_dict(dict=pred_dict)) path_file = "./statistical_test_prob/" + FLAGS.model + "_checking.txt" write_file(path_file=path_file, data=pred_dict_list) if __name__ == "__main__": tf_ = model_parameters() FLAGS_ = tf_.flags.FLAGS print_params(tf_) folds_, random_state_ = 5, None loading_baseline_july(tf=tf_, folds=folds_, random_state=random_state_)