# Part 1 - Perceptron Algorithm #------------------------------------------------------------------------------- toy_features, toy_labels = utils.load_toy_data('../../Data/toy_data.csv') theta, theta_0 = lab2.perceptron(toy_features, toy_labels, T=5) utils.plot_toy_results(toy_features, toy_labels, theta, theta_0) #------------------------------------------------------------------------------- # Part 2 - Classifying Reviews #------------------------------------------------------------------------------- theta, theta_0 = lab2.perceptron(train_bow_features, train_labels, T=5) train_accuracy = lab2.accuracy(train_bow_features, train_labels, theta, theta_0) val_accuracy = lab2.accuracy(val_bow_features, val_labels, theta, theta_0) print("Training accuracy: {:.4f}".format(train_accuracy)) print("Validation accuracy: {:.4f}".format(val_accuracy)) #------------------------------------------------------------------------------- # Part 3 - Improving the Model #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Part 3.1 - Tuning the Hyperparameters #------------------------------------------------------------------------------- # Ts = [1, 5, 10, 15, 20]
# Part 1 - Perceptron Algorithm #------------------------------------------------------------------------------- toy_features, toy_labels = utils.load_toy_data('../../Data/toy_data.csv') theta, theta_0 = lab2.perceptron(toy_features, toy_labels, T=5) utils.plot_toy_results(toy_features, toy_labels, theta, theta_0) #------------------------------------------------------------------------------- # Part 2 - Classifying Reviews #------------------------------------------------------------------------------- theta, theta_0 = lab2.perceptron(train_bow_features, train_labels, T=5) train_accuracy = lab2.accuracy(train_bow_features, train_labels, theta, theta_0) val_accuracy = lab2.accuracy(val_bow_features, val_labels, theta, theta_0) print("Training accuracy: {:.4f}".format(train_accuracy)) # 0.9850 print("Validation accuracy: {:.4f}".format(val_accuracy)) # 0.8943 #------------------------------------------------------------------------------- # Part 3 - Improving the Model #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Part 3.1 - Tuning the Hyperparameters #------------------------------------------------------------------------------- Ts = [1, 5, 10, 15, 20]
# Part 1 - Perceptron Algorithm #------------------------------------------------------------------------------- # toy_features, toy_labels = utils.load_toy_data('../../Data/toy_data.csv') # # theta, theta_0 = lab2.perceptron(toy_features, toy_labels, T=5) # # utils.plot_toy_results(toy_features, toy_labels, theta, theta_0) #------------------------------------------------------------------------------- # Part 2 - Classifying Reviews #------------------------------------------------------------------------------- theta, theta_0 = lab2.perceptron(train_bow_features, train_labels, T=5) train_accuracy = lab2.accuracy(train_bow_features, train_labels, theta, theta_0) val_accuracy = lab2.accuracy(val_bow_features, val_labels, theta, theta_0) # # print("Training accuracy: {:.4f}".format(train_accuracy)) # print("Validation accuracy: {:.4f}".format(val_accuracy)) #------------------------------------------------------------------------------- # Part 3 - Improving the Model #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Part 3.1 - Tuning the Hyperparameters #------------------------------------------------------------------------------- # Ts = [1, 5, 10, 15, 20]