def test(X, y, learned_params): N = np.shape(X)[0] #no of instances X = np.append(np.ones((N,1)), X,1) #appending a column of ones as bias (used in logistic regression weights prediction) F = np.shape(X)[1] #no of features+1 class_prob = [] for w in learned_params.keys(): prob = Utils.logistic_transformation(learned_params[w], X) class_prob.append(prob) max_prob = np.max(class_prob, 0) predicted_y = [] output_label = range(min_class_label, max_class_label+1) for i in xrange(np.size(max_prob)): class_label = np.where(class_prob == max_prob[i])[0] predicted_y.append(output_label[class_label[0]]) print "predicted y :", predicted_y print "Actual y:", y accuracy = Utils.calculate_accuracy(np.array(y), np.array(predicted_y)) print "accuracy for test data :", accuracy f_score_mean, f_score_std = Utils.calculate_average_F1score(np.array(y), np.array(predicted_y), min_class_label, max_class_label) print "Average f score for test data :", f_score_mean error_rate = Utils.calculate_error_rate(np.array(y), np.array(predicted_y)) #ch = stdin.read(1) return (accuracy, f_score_mean, f_score_std, error_rate)