def main(args): if not args.extra: train_set, train_labels, dev_set, dev_labels = reader.load_dataset( args.dataset_file) pred_p = c.classifyPerceptron(train_set, train_labels, dev_set, args.lrate, args.max_iter) print("Perceptron") accuracy, f1, precision, recall = compute_accuracies( pred_p, dev_set, dev_labels) pred_lr = c.classifyLR(train_set, train_labels, dev_set, args.lrate, args.max_iter) print("\nLogistic Regression") accuracy, f1, precision, recall = compute_accuracies( pred_lr, dev_set, dev_labels) else: train_set, train_labels, dev_set, dev_labels = reader.load_dataset( args.dataset_file, extra=True) predicted_labels = c.classifyEC(train_set, train_labels, dev_set, args.k) print("kNN, k = {}".format(args.k)) accuracy, f1, precision, recall = compute_accuracies( predicted_labels, dev_set, dev_labels)
def main(args): if args.method == 'perceptron': train_set, train_labels, dev_set,dev_labels = reader.load_dataset(args.dataset_file) pred_p = c.classifyPerceptron(train_set, train_labels, dev_set, args.lrate, args.max_iter) print("Perceptron") accuracy,f1,precision,recall = compute_accuracies(pred_p, dev_labels) elif args.method == 'knn': train_set, train_labels, dev_set,dev_labels = reader.load_dataset(args.dataset_file, extra=True) predicted_labels = c.classifyKNN(train_set, train_labels, dev_set, args.k) print("kNN, k = {}".format(args.k)) accuracy,f1,precision,recall = compute_accuracies(predicted_labels, dev_labels) else: print("Method must be either perceptron or knn!")