def cartesBienClusterisees(couche="conv1",
                           seuilSuppression=559,
                           seuilBonClustering=30,
                           fichier=False):

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, ind = MapsClustering(
        couche, seuilSuppression, "kmeansNonInit", fichier)
    pFRJA_R_KMI, pFRJA_V_KMI, pFR_RV_KMI, pCIC_R_KMI, pCIC_V_KMI, indKmeansInit = MapsClustering(
        couche, seuilSuppression, "kmeansInit", fichier)
    pFRJA_R_DBSCAN, pFRJA_V_DBSCAN, pFR_RV_DBSCAN, pCIC_R_DBSCAN, pCIC_V_DBSCAN, indDBSCAN = MapsClustering(
        couche, seuilSuppression, "DBSCAN", fichier)
    # pFRJA_R_MeanShift, pFRJA_V_MeanShift, pFR_RV_MeanShift, pCIC_R_MeanShift, pCIC_V_MeanShift, indMeanShift = MapsClustering(couche, seuilSuppression, "MeanShift", fichier)

    ################################################################################
    #Initialisation des matrices
    ################################################################################

    bienClusterisesKmeansNonInit = []
    bienClusterisesKmeansInit = []
    bienClusterisesDBSCAN = []
    # bienClusterisesMeanShift = []

    ################################################################################
    #Clustering 1
    ################################################################################
    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[0])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_R_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[0])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_R_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[0])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[0])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 1bis
    ################################################################################

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[1])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[1])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_V_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[1])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[1])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 2
    ################################################################################

    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[2])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFR_RV_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[2])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFR_RV_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[2])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[2])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 3
    ################################################################################

    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[3])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_R_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[3])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_R_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[3])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[3])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 3bis
    ################################################################################

    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[4])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_V_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[4])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_V_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[4])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[4])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Enregistrement des differentes matrices
    ################################################################################
    np.save(
        '../resultats/' + couche +
        '/kmeansNonInit/bienClusterisekmeansNonInit.npy',
        bienClusterisesKmeansNonInit)
    np.save(
        '../resultats/' + couche + '/kmeansInit/bienClusterisekmeansInit.npy',
        bienClusterisesKmeansInit)
    np.save('../resultats/' + couche + '/DBSCAN/bienClusteriseDBSCAN.npy',
            bienClusterisesDBSCAN)
Beispiel #2
0
def GenerationClustering(couche="conv1",
                         seuilSuppression=559,
                         seuilBonClustering=30,
                         fichier=True):

    #############################################################################################
    # Appel de MapsClustering et enregistrement des matrices des indices pour chaque algorithme de chaque couche;
    # Matrice des indices : 5 colonnes representant les 5 clusterings, et dans chaque colonne les indices de cartes
    # qui donnent bien deux classes.
    #############################################################################################

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, ind = MapsClustering(
        couche, seuilSuppression, "kmeansNonInit", fichier)
    matKmeansNonInit = str(
        "../resultats/" + couche +
        "/kmeansNonInit/matKmeansNonInit_indices_bonnes_cartes.csv")
    f1 = open(matKmeansNonInit, "wb")
    writer = csv.writer(f1)
    writer.writerow([
        "KmeansNonInit(1)", "KmeansNonInit(1bis)", "KmeansNonInit(2)",
        "KmeansNonInit(2bis)", "KmeansNonInit(3)"
    ])
    for values in izip_longest(*ind):
        writer.writerow(values)

    pFRJA_R_KMI, pFRJA_V_KMI, pFR_RV_KMI, pCIC_R_KMI, pCIC_V_KMI, indKmeansInit = MapsClustering(
        couche, seuilSuppression, "kmeansInit", fichier)
    matKmeansInit = str("../resultats/" + couche +
                        "/kmeansInit/matKmeansInit_indices_bonnes_cartes.csv")
    f2 = open(matKmeansInit, "wb")
    writer = csv.writer(f2)
    writer.writerow([
        "KmeansInit(1)", "KmeansInit(1bis)", "KmeansInit(2)",
        "KmeansInit(2bis)", "KmeansInit(3)"
    ])
    for values in izip_longest(*indKmeansInit):
        writer.writerow(values)

    pFRJA_R_DBSCAN, pFRJA_V_DBSCAN, pFR_RV_DBSCAN, pCIC_R_DBSCAN, pCIC_V_DBSCAN, indDBSCAN = MapsClustering(
        couche, seuilSuppression, "DBSCAN", fichier)
    matDBSCAN = str("../resultats/" + couche +
                    "/DBSCAN/matDBSCAN_indices_bonnes_cartes.csv")
    f3 = open(matDBSCAN, "wb")
    writer = csv.writer(f3)
    writer.writerow([
        "DBSCAN(1)", "DBSCAN(1bis)", "DBSCAN(2)", "DBSCAN(2bis)", "DBSCAN(3)"
    ])
    for values in izip_longest(*indDBSCAN):
        writer.writerow(values)

    # pFRJA_R_MeanShift, pFRJA_V_MeanShift, pFR_RV_MeanShift, pCIC_R_MeanShift, pCIC_V_MeanShift, indMeanShift = MapsClustering(couche, seuilSuppression, "MeanShift", fichier)
    # matMeanShift = str("../resultats/" + couche + "/MeanShift/matMeanShift_indices_bonnes_cartes.csv")
    # f4 = open(matMeanShift, "wb")
    # writer = csv.writer(f4)
    # writer.writerow(["MeanShift(1)", "MeanShift(1bis)", "MeanShift(2)", "MeanShift(2bis)", "MeanShift(3)"])
    # for values in izip_longest(*indMeanShift):
    #     writer.writerow(values)

    #############################################################################################
    # Fichiers de cartes bon clustering
    #############################################################################################

    filename = str("../resultats/" + couche + "/cartes_bon_clustering22")
    f = open(filename, "wb")

    #############################################################################
    #appel directement avec les matrices
    ##############################################################################

    f.write("FRJA R\n")

    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[0])
    f.write("kmeansNonInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFRJA_R_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[0])
    f.write("kmeansInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFRJA_R_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[0])
    f.write("DBSCAN:" + str(clus) + "\n")
    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering,indices= indMeanShift[0])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.write("FRJA V\n")

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[1])
    f.write("kmeansNonInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFRJA_V_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[1])
    f.write("kmeansInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFRJA_V_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[1])
    f.write("DBSCAN:" + str(clus) + "\n")
    # clus = bienClusterise(MatriceClustering=pFRJA_V_MeanShift, seuil=seuilBonClustering,indices= indMeanShift[1])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.write("FR  RV\n")

    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[2])
    f.write("kmeansNonInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFR_RV_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[2])
    f.write("kmeansInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pFR_RV_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[2])
    f.write("DBSCAN:" + str(clus) + "\n")
    # clus = bienClusterise(MatriceClustering=pFR_RV_MeanShift, seuil=seuilBonClustering,  indices= indMeanShift[2])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.write("JA correct/incorrect R\n")

    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[3])
    f.write("kmeansNonInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pCIC_R_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[3])
    f.write("kmeansInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pCIC_R_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[3])
    f.write("DBSCAN:" + str(clus) + "\n")
    # clus = bienClusterise(MatriceClustering=pCIC_R_MeanShift, seuil=seuilBonClustering,  indices= indMeanShift[3])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.write("JA correct/incorrect V\n")

    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI,
                          seuil=seuilBonClustering,
                          indices=ind[4])
    f.write("kmeansNonInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pCIC_V_KMI,
                          seuil=seuilBonClustering,
                          indices=indKmeansInit[4])
    f.write("kmeansInit:" + str(clus) + "\n")
    clus = bienClusterise(MatriceClustering=pCIC_V_DBSCAN,
                          seuil=seuilBonClustering,
                          indices=indDBSCAN[4])
    f.write("DBSCAN:" + str(clus) + "\n")
    # clus = bienClusterise(MatriceClustering=pCIC_V_MeanShift, seuil=seuilBonClustering, indices= indMeanShift[4])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.close()
def GenerationClustering(couche = "conv1", seuilSuppression = 559, seuilBonClustering = 30, fichier = True):

    #############################################################################################
    # Appel de MapsClustering et enregistrement des matrices des indices pour chaque algorithme de chaque couche;
    # Matrice des indices : 5 colonnes representant les 5 clusterings, et dans chaque colonne les indices de cartes
    # qui donnent bien deux classes.
    #############################################################################################

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, ind = MapsClustering(couche, seuilSuppression, "kmeansNonInit", fichier)
    matKmeansNonInit = str("../resultats/" + couche + "/kmeansNonInit/matKmeansNonInit_indices_bonnes_cartes.csv")
    f1 = open(matKmeansNonInit, "wb")
    writer = csv.writer(f1)
    writer.writerow(["KmeansNonInit(1)", "KmeansNonInit(1bis)", "KmeansNonInit(2)", "KmeansNonInit(2bis)", "KmeansNonInit(3)"])
    for values in izip_longest(*ind):
        writer.writerow(values)

    pFRJA_R_KMI, pFRJA_V_KMI, pFR_RV_KMI, pCIC_R_KMI, pCIC_V_KMI, indKmeansInit = MapsClustering(couche, seuilSuppression, "kmeansInit", fichier)
    matKmeansInit = str("../resultats/" + couche + "/kmeansInit/matKmeansInit_indices_bonnes_cartes.csv")
    f2 = open(matKmeansInit, "wb")
    writer = csv.writer(f2)
    writer.writerow(["KmeansInit(1)", "KmeansInit(1bis)", "KmeansInit(2)", "KmeansInit(2bis)", "KmeansInit(3)"])
    for values in izip_longest(*indKmeansInit):
        writer.writerow(values)


    pFRJA_R_DBSCAN, pFRJA_V_DBSCAN, pFR_RV_DBSCAN, pCIC_R_DBSCAN, pCIC_V_DBSCAN, indDBSCAN = MapsClustering(couche, seuilSuppression, "DBSCAN", fichier)
    matDBSCAN = str("../resultats/" + couche + "/DBSCAN/matDBSCAN_indices_bonnes_cartes.csv")
    f3 = open(matDBSCAN, "wb")
    writer = csv.writer(f3)
    writer.writerow(["DBSCAN(1)", "DBSCAN(1bis)", "DBSCAN(2)", "DBSCAN(2bis)", "DBSCAN(3)"])
    for values in izip_longest(*indDBSCAN):
        writer.writerow(values)

    # pFRJA_R_MeanShift, pFRJA_V_MeanShift, pFR_RV_MeanShift, pCIC_R_MeanShift, pCIC_V_MeanShift, indMeanShift = MapsClustering(couche, seuilSuppression, "MeanShift", fichier)
    # matMeanShift = str("../resultats/" + couche + "/MeanShift/matMeanShift_indices_bonnes_cartes.csv")
    # f4 = open(matMeanShift, "wb")
    # writer = csv.writer(f4)
    # writer.writerow(["MeanShift(1)", "MeanShift(1bis)", "MeanShift(2)", "MeanShift(2bis)", "MeanShift(3)"])
    # for values in izip_longest(*indMeanShift):
    #     writer.writerow(values)



    #############################################################################################
    # Fichiers de cartes bon clustering
    #############################################################################################

    filename = str("../resultats/" + couche + "/cartes_bon_clustering_MeanShift")
    f = open(filename, "wb")

    #############################################################################
    #appel directement avec les matrices
    ##############################################################################

    f.write("FRJA R\n")


    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI, seuil=seuilBonClustering, indices=ind[0])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFRJA_R_KMI, seuil=seuilBonClustering, indices=indKmeansInit[0])
    f.write("kmeansInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFRJA_R_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[0])
    f.write("DBSCAN:"+ str(clus)+"\n")

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering,indices= indMeanShift[0])
    # f.write("MeanShift:" + str(clus)+"\n")


    f.write("FRJA V\n")

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI, seuil=seuilBonClustering,  indices=ind[1])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFRJA_V_KMI, seuil=seuilBonClustering, indices=indKmeansInit[1])
    f.write("kmeansInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFRJA_V_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[1])
    f.write("DBSCAN:" + str(clus)+"\n")
    # clus = bienClusterise(MatriceClustering=pFRJA_V_MeanShift, seuil=seuilBonClustering,indices= indMeanShift[1])
    # f.write("MeanShift:" + str(clus)+"\n")


    f.write("FR  RV\n")
    #
    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI, seuil=seuilBonClustering,  indices=ind[2])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFR_RV_KMI, seuil=seuilBonClustering,indices=indKmeansInit[2])
    f.write("kmeansInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pFR_RV_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[2])
    f.write("DBSCAN:" + str(clus)+"\n")
    # clus = bienClusterise(MatriceClustering=pFR_RV_MeanShift, seuil=seuilBonClustering,  indices= indMeanShift[2])
    # f.write("MeanShift:" + str(clus)+"\n")


    f.write("JA correct/incorrect R\n")

    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI, seuil=seuilBonClustering,  indices=ind[3])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pCIC_R_KMI, seuil=seuilBonClustering, indices=indKmeansInit[3])
    f.write("kmeansInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pCIC_R_DBSCAN, seuil=seuilBonClustering,  indices=indDBSCAN[3])
    f.write("DBSCAN:"+ str(clus)+"\n")
    # clus = bienClusterise(MatriceClustering=pCIC_R_MeanShift, seuil=seuilBonClustering,  indices= indMeanShift[3])
    # f.write("MeanShift:" + str(clus)+"\n")


    f.write("JA correct/incorrect V\n")

    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI, seuil=seuilBonClustering,  indices=ind[4])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pCIC_V_KMI, seuil=seuilBonClustering,indices=indKmeansInit[4])
    f.write("kmeansInit:" + str(clus)+"\n")
    clus = bienClusterise(MatriceClustering=pCIC_V_DBSCAN, seuil=seuilBonClustering,  indices=indDBSCAN[4])
    f.write("DBSCAN:" + str(clus)+"\n")
    # clus = bienClusterise(MatriceClustering=pCIC_V_MeanShift, seuil=seuilBonClustering, indices= indMeanShift[4])
    # f.write("MeanShift:" + str(clus)+"\n")

    f.close()
def cartesBienClusterisantes(couche = "conv1", seuilSuppression = 559, seuilBonClustering = 30, fichier = False):

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, ind = MapsClustering(couche, seuilSuppression, "kmeansNonInit", fichier)
    pFRJA_R_KMI, pFRJA_V_KMI, pFR_RV_KMI, pCIC_R_KMI, pCIC_V_KMI, indKmeansInit = MapsClustering(couche, seuilSuppression, "kmeansInit", fichier)
    pFRJA_R_DBSCAN, pFRJA_V_DBSCAN, pFR_RV_DBSCAN, pCIC_R_DBSCAN, pCIC_V_DBSCAN, indDBSCAN = MapsClustering(couche, seuilSuppression, "DBSCAN", fichier)
    # pFRJA_R_MeanShift, pFRJA_V_MeanShift, pFR_RV_MeanShift, pCIC_R_MeanShift, pCIC_V_MeanShift, indMeanShift = MapsClustering(couche, seuilSuppression, "MeanShift", fichier)

    ################################################################################
    #Initialisation des matrices
    ################################################################################

    bienClusterisesKmeansNonInit = []
    bienClusterisesKmeansInit = []
    bienClusterisesDBSCAN = []
    # bienClusterisesMeanShift = []


    ################################################################################
    #Clustering 1
    ################################################################################
    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI, seuil=seuilBonClustering, indices=ind[0])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_R_KMI, seuil=seuilBonClustering, indices=indKmeansInit[0])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_R_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[0])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[0])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 1bis
    ################################################################################

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI, seuil=seuilBonClustering,  indices=ind[1])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMI, seuil=seuilBonClustering, indices=indKmeansInit[1])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFRJA_V_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[1])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[1])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 2
    ################################################################################

    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI, seuil=seuilBonClustering,  indices=ind[2])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFR_RV_KMI, seuil=seuilBonClustering,indices=indKmeansInit[2])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pFR_RV_DBSCAN, seuil=seuilBonClustering, indices=indDBSCAN[2])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[2])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 3
    ################################################################################

    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI, seuil=seuilBonClustering,  indices=ind[3])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_R_KMI, seuil=seuilBonClustering, indices=indKmeansInit[3])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_R_DBSCAN, seuil=seuilBonClustering,  indices=indDBSCAN[3])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[3])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Clustering 3bis
    ################################################################################

    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI, seuil=seuilBonClustering,  indices=ind[4])
    bienClusterisesKmeansNonInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_V_KMI, seuil=seuilBonClustering,indices=indKmeansInit[4])
    bienClusterisesKmeansInit.append(clus)

    clus = bienClusterise(MatriceClustering=pCIC_V_DBSCAN, seuil=seuilBonClustering,  indices=indDBSCAN[4])
    bienClusterisesDBSCAN.append(clus)

    # clus = bienClusterise(MatriceClustering=pFRJA_R_MeanShift, seuil=seuilBonClustering, indices=indMeanShift[4])
    # bienClusterisesMeanShift.append(clus)

    ################################################################################
    #Enregistrement des differentes matrices
    ################################################################################
    np.save('../resultats/' + couche + '/kmeansNonInit/bienClusteriseKmeansNonInit.npy', bienClusterisesKmeansNonInit)
    np.save('../resultats/' + couche + '/kmeansInit/bienClusteriseKmeansInit.npy', bienClusterisesKmeansInit)
    np.save('../resultats/' + couche + '/DBSCAN/bienClusteriseDBSCAN.npy', bienClusterisesDBSCAN)
    # np.save('../resultats/' + couche + '/MeanShift/bienClusteriseMeanShift.npy', bienClusterisesMeanShift)
def GenerationClustering(couche = "conv1", seuilSuppression = 559, seuilBonClustering = 30, fichier = True):

    #############################################################################################
    # Appel de MapsClustering et enregistrement des matrices des indices pour chaque algorithme de chaque couche;
    # Matrice des indices : 5 colonnes representant les 5 clusterings, et dans chaque colonne les indices de cartes
    # qui donnent bien deux classes.
    #############################################################################################

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, pourcentagesFR_Rlvb0, pourcentagesFR_Rlvb1,pourcentagesFR_Rlvb2, pourcentagesFR_Rlvb3, ind = Maps5Clustering(couche, seuilSuppression, fichier)
    matKmeansNonInit = str("../resultats/resultats5phonemes/matKmeansNonInit_indices_bonnes_cartes.csv")
    f1 = open(matKmeansNonInit, "wb")
    writer = csv.writer(f1)
    writer.writerow(["KmeansNonInit(1)", "KmeansNonInit(1bis)", "KmeansNonInit(2)", "KmeansNonInit(3)", "KmeansNonInit(3bis)", " 4phonemes"])
    for values in izip_longest(*ind):
        writer.writerow(values)



    #############################################################################################
    # Fichiers de cartes bon clustering
    #############################################################################################

    filename = str("../resultats/resultats5phonemes/cartes_bon_clustering_kmeans5")
    f = open(filename, "wb")

    #############################################################################
    #appel directement avec les matrices
    ##############################################################################

    f.write("FRJA R\n")


    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI, seuil=seuilBonClustering, indices=ind[0])
    f.write("kmeansNonInit:" + str(clus)+"\n")


    f.write("FRJA V\n")

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI, seuil=seuilBonClustering,  indices=ind[1])
    f.write("kmeansNonInit:" + str(clus)+"\n")


    f.write("FR  RV\n")

    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI, seuil=seuilBonClustering,  indices=ind[2])
    f.write("kmeansNonInit:" + str(clus)+"\n")



    f.write("JA correct/incorrect R\n")
    #
    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI, seuil=seuilBonClustering,  indices=ind[3])
    f.write("kmeansNonInit:" + str(clus)+"\n")



    f.write("JA correct/incorrect V\n")
    #
    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI, seuil=seuilBonClustering,  indices=ind[4])
    f.write("kmeansNonInit:" + str(clus)+"\n")

    f.write("FR_Rlvb\n")

    f.write("classe0")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb0, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe1")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb1, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe2")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb2, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe3")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb3, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")

    f.close()
Beispiel #6
0
def GenerationClustering(couche = "conv1", seuilSuppression = 559, seuilBonClustering = 30, fichier = True):

    #############################################################################################
    # Appel de MapsClustering et enregistrement des matrices des indices pour chaque algorithme de chaque couche;
    # Matrice des indices : 5 colonnes representant les 5 clusterings, et dans chaque colonne les indices de cartes
    # qui donnent bien deux classes.
    #############################################################################################

    pFRJA_R_KMNI, pFRJA_V_KMNI, pFR_RV_KMNI, pCIC_R_KMNI, pCIC_V_KMNI, pourcentagesFR_Rlvb0, pourcentagesFR_Rlvb1,pourcentagesFR_Rlvb2, pourcentagesFR_Rlvb3, ind = Maps5Clustering(couche, seuilSuppression, fichier)
    matKmeansNonInit = str("../resultats/resultats5phonemes/matKmeansNonInit_indices_bonnes_cartes.csv")
    f1 = open(matKmeansNonInit, "wb")
    writer = csv.writer(f1)
    writer.writerow(["KmeansNonInit(1)", "KmeansNonInit(1bis)", "KmeansNonInit(2)", "KmeansNonInit(3)", "KmeansNonInit(3bis)", " 4phonemes"])
    for values in izip_longest(*ind):
        writer.writerow(values)



    #############################################################################################
    # Fichiers de cartes bon clustering
    #############################################################################################

    filename = str("../resultats/resultats5phonemes/cartes_bon_clustering_kmeans5")
    f = open(filename, "wb")

    #############################################################################
    #appel directement avec les matrices
    ##############################################################################

    f.write("FRJA R\n")


    clus = bienClusterise(MatriceClustering=pFRJA_R_KMNI, seuil=seuilBonClustering, indices=ind[0])
    f.write("kmeansNonInit:" + str(clus)+"\n")


    f.write("FRJA V\n")

    clus = bienClusterise(MatriceClustering=pFRJA_V_KMNI, seuil=seuilBonClustering,  indices=ind[1])
    f.write("kmeansNonInit:" + str(clus)+"\n")


    f.write("FR  RV\n")

    clus = bienClusterise(MatriceClustering=pFR_RV_KMNI, seuil=seuilBonClustering,  indices=ind[2])
    f.write("kmeansNonInit:" + str(clus)+"\n")



    f.write("JA correct/incorrect R\n")
    #
    clus = bienClusterise(MatriceClustering=pCIC_R_KMNI, seuil=seuilBonClustering,  indices=ind[3])
    f.write("kmeansNonInit:" + str(clus)+"\n")



    f.write("JA correct/incorrect V\n")
    #
    clus = bienClusterise(MatriceClustering=pCIC_V_KMNI, seuil=seuilBonClustering,  indices=ind[4])
    f.write("kmeansNonInit:" + str(clus)+"\n")

    f.write("FR_Rlvb\n")

    f.write("classe0")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb0, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe1")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb1, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe2")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb2, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")
    f.write("classe3")
    clus = bienClusterise(MatriceClustering=pourcentagesFR_Rlvb3, seuil=seuilBonClustering,  indices=ind[5])
    f.write("kmeansNonInit:" + str(clus)+"\n")

    f.close()