Exemple #1
0
            if mean < minMean:
                minMean = mean

            if mean > maxMean:
                maxMean = mean

            if std > maxStd:
                maxStd = std

    l = 2*(minMean - maxStd)
    r = 2*(maxMean + maxStd)

    for m, s in toPlot:
        normDist(m,s,l,r)

formt = FormatJson(sys.argv[1])
naive = NaiveBayes(formt.data())
print "Total Accuracy (cross validate) = " +  str(naive.crossValidate(10))

labels = formt.channels()
counts = [[0]*len(labels) for i in range(len(labels))]

for label, data in formt.data():
    expectedChn, _ = naive.predict(data)

    # Confusion matrix
    correct = labels.index(label)
    actual = labels.index(expectedChn)
    counts[correct][actual] += 1

print counts
Exemple #2
0
names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Decision Tree",
         "Random Forest", "Naive Bayes", "MultinomialNB", "LDA", "QDA"]
classifiers = [
    KNeighborsClassifier(3),
    SVC(kernel="linear", C=0.025),
    SVC(gamma=2, C=1),
    DecisionTreeClassifier(max_depth=5),
    RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),
    #AdaBoostClassifier(),
    GaussianNB(),
    MultinomialNB(1.0, True),
    LDA(),
    QDA()]

formater = FormatJson(sys.argv[1])
data = formater.data()

x = []
y = []

for l, d in data:
    x.append(d)

    if l == "17 Hz":
        y.append(1)
    else:
        y.append(0)

X = np.asarray(x)
Y = np.asarray(y)