Esempio n. 1
0
def testKNNBrut(mult_donnees):
    print("debut test knn brut")
    result = []
    for r, donnees in mult_donnees.items():
        print("r = " + str(r))
        neigh = KNeighborsClassifier(n_neighbors=3)
        m = GenericModele(neigh, donnees)
        m.vectorize()
        s = m.f1Score()
        result.append([r, s])
    print("reactionTime,f1score : " + str(result))
    return result
Esempio n. 2
0
def testSVMBrut(mult_donnees):
    print("debut test SVM brut")
    result = []
    for r, donnees in mult_donnees.items():
        print("r = " + str(r))
        clf = SVC(gamma='auto', probability=True, max_iter=100, verbose=1)
        m = GenericModele(clf, donnees)
        m.vectorize()
        s = m.f1Score()
        result.append([r, s])
    print("reactionTime,f1score : " + str(result))
    return result
Esempio n. 3
0
def testSVMPaseBas(nbPoint, slider, mult_donnees):
    print("debut test passe bas SVM")
    result = []
    for r, donnees in mult_donnees.items():
        print("r = " + str(r))
        clf = SVC(gamma='auto', probability=True, max_iter=100, verbose=1)
        m = GenericModele(clf, donnees)
        m.vectorize()
        m.dataToMoy(nbPoint, slider)
        s = m.f1Score()
        result.append([r, s])
    print("reactionTime,f1score : " + str(result))
    return result
Esempio n. 4
0
def testKNNPaseBas(nbPoint, slider, mult_donnees):
    print("debut test passe bas knn")
    result = []
    for r, donnees in mult_donnees.items():
        print("r = " + str(r))
        neigh = KNeighborsClassifier(n_neighbors=3)
        m = GenericModele(neigh, donnees)
        m.vectorize()
        m.dataToMoy(nbPoint, slider)
        s = m.f1Score()
        result.append([r, s])
    print("reactionTime,f1score : " + str(result))
    return result
def testCovSVM(mult_donnees,mesDonnees_test):
    print("debut test cov SVM")
    result=[]
    for r,donnees in mult_donnees.items():
        print("r = "+str(r))
        clf = SVC(gamma='auto',probability=True,max_iter=100,verbose=1)
        m = GenericModele(clf,donnees)
        m.dataToCov()
        m.vectorize()
        m.fit()
        s = m.score(mesDonnees_test[r].data,mesDonnees_test[r].labels)
        result.append([r,s])
    print("reactionTime,f1score : "+str(result))
    return result
def testKNNTF(mult_donnees,mesDonnees_test):
    print("debut test knn tf")
    result=[]
    for r,donnees in mult_donnees.items():
        print("r = "+str(r))
        neigh = KNeighborsClassifier(n_neighbors=3)
        m = GenericModele(neigh,donnees)
        m.dataToTf()
        m.vectorize(tf=True)
        m.fit()
        s = m.score(mesDonnees_test[r].data,mesDonnees_test[r].labels)
        result.append([r,s])
    print("reactionTime,f1score : "+str(result))
    return result
Esempio n. 7
0

myFileList = ["data/subject1/Session1/1.gdf"]
reactTimeToTest = [1, 0.1, 0.04]

mesDonnees = dict()
for r in reactTimeToTest:
    mesDonnees[r] = dataLoader.DataLoader(myFileList, r)

os.mkdir("resultats/TFKNN_valeurs_k")
for r, donnees in mesDonnees.items():
    print(r)
    result = []
    for k in range(1, 20, 2):
        neigh = KNeighborsClassifier(n_neighbors=k)
        m = GenericModele(neigh, donnees)
        m.dataToTf()
        m.vectorize(tf=True)
        m.dataToMoy(nbPoint, slider)
        s = m.f1Score()
        result.append([k, s])
    plt.clf()
    f = plt.figure()
    plt.title("F1 score en fonction de la valeur de k")
    plt.xlabel("Valeur de k")
    plt.ylabel("F1 score")
    plt.plot([re[0] for re in result], [re[1] for re in result])
    name = "resultats/TFKNN_valeurs_k/KNN_tf_valeur_de_k_pour_time_" + str(r)
    f.savefig(name + ".pdf", bbox_inches='tight')
    saveResult(name + ".csv", result)
Esempio n. 8
0

myFileList = ["data/subject1/Session1/1.gdf"]
reactTimeToTest = [1, 0.1, 0.04]

mesDonnees = dict()
for r in reactTimeToTest:
    mesDonnees[r] = dataLoader.DataLoader(myFileList, r)

os.mkdir("resultats/PasseBasKNN_valeurs_k")
for r, donnees in mesDonnees.items():
    print(r)
    result = []
    for k in range(1, 20, 2):
        neigh = KNeighborsClassifier(n_neighbors=k)
        m = GenericModele(neigh, donnees)
        m.vectorize()
        m.dataToMoy(nbPoint, slider)
        s = m.f1Score()
        result.append([k, s])
    plt.clf()
    f = plt.figure()
    plt.title("F1 score en fonction de la valeur de k")
    plt.xlabel("Valeur de k")
    plt.ylabel("F1 score")
    plt.plot([re[0] for re in result], [re[1] for re in result])
    name = "resultats/PasseBasKNN_valeurs_k/KNN_passeBas_valeur_de_k_pour_time_" + str(
        r)
    f.savefig(name + ".pdf", bbox_inches='tight')
    saveResult(name + ".csv", result)