def q3a():
    """ A - Dual version on Perceptron
        B - Spirals
        Try to run the dual perceptron (with dot product) and conclude that the perceptron does not work.  Then run the dual perceptron with the Gaussian kernel and conclude the data is now separable.
        Expected accuracy dot product kernel : 50% average oscillating between 66% and 33%
        Expected accuracy with RBF kernel : 99.9% (depends on sigma)
    """
    np.random.seed(2)
    test, train = utils.load_perceptron_data()
    c = train.columns[:-1]
    y_train = list(train[4])
    X_train = train[c].as_matrix()
    y_test = list(test[4])
    X_test = test[c].as_matrix()

    dual_perc = dperc.DualPerceptron(T=100)
    dual_perc.fit(X_train, y_train)
    y_pred = dual_perc.predict(X_test)
    print '3a: Dual Percepton AUC: {}'.format(roc_auc_score(y_test, dual_perc.decision_function(X_test)))
    print '3a: Dual Percepton Accuracy (train): {}'.format(accuracy_score(y_train, dual_perc.predict(X_train)))
    print '3a: Dual Percepton Accuracy (test): {}'.format(accuracy_score(y_test, y_pred))
def q_2():
    """ Perceptron """
    test, train = utils.load_perceptron_data()
    print test[4]
    print train.head(5)
    model = perc.Perceptron(train, 4, 0.05, 100)