Ejemplo n.º 1
0
    #   Split the data into test and train data
    test_pcnt = 0.15
    X_train = X[:int(len(X) * (1 - test_pcnt)), :]
    X_test = X[int(len(X) * (1 - test_pcnt)):, :]
    y_train = y[:int(len(X) * (1 - test_pcnt))]
    y_test = y[int(len(X) * (1 - test_pcnt)):]

    ytrue = y_train

    print X_train.shape, y_train.shape

    # Just supervised score
    basemodel = WQDA()  # weighted Quadratic Discriminant Analysis
    #basemodel = SGDClassifier(loss='log', penalty='l1') # scikit logistic regression
    basemodel.fit(X_train, ytrue)
    print "full labeled wqda score", basemodel.score(X_test, y_test)
    print "standard error of wqda", 1.96 * np.sqrt(
        basemodel.score(X_test, y_test) *
        (1 - basemodel.score(X_test, y_test)) / X_test.shape[0])

    # Just supervised score
    #basemodel = WQDA() # weighted Quadratic Discriminant Analysis
    basemodel = SGDClassifier(loss='log',
                              penalty='l1')  # scikit logistic regression
    basemodel.fit(X_train, ytrue)
    print "full labeled log.reg. score", basemodel.score(X_test, y_test)
    print "standard error of log reg", 1.96 * np.sqrt(
        basemodel.score(X_test, y_test) *
        (1 - basemodel.score(X_test, y_test)) / X_test.shape[0])

    super_acc = np.zeros(num_trials)