print ccr(crossDatasetTrueClassification, clusteringResults) # print labelAssignment fileContainer.write('\n') fileContainer.write('The Correct Clustering Rate is : '+ str(ccr(crossDatasetTrueClassification, clusteringResults))) fileContainer.write('\n') fileContainer.write('The clustering Jaccard Similarity is : '+ str(jaccardSim(crossDatasetTrueClassification, clusteringResults))) wholeTrueClasses = np.zeros(1900) for i, trueClass in enumerate(crossDatasetTrueClassification): for trajectory in trueClass: wholeTrueClasses[trueClass] = i print list(wholeTrueClasses[:20]) wholePredClasses = np.zeros(1900) for i, predClass in enumerate(clusteringResults): for trajectory in predClass: wholePredClasses[predClass] = i print list(wholePredClasses[:20]) print normalized_mutual_info_score(wholeTrueClasses, wholePredClasses) fileContainer.write('\nThe NMI is : '+ str(normalized_mutual_info_score(wholeTrueClasses, wholePredClasses))) fileContainer.write('\n--------------------------------------------------------------------') print measurements.ccr(crossDatasetTrueClassification, clusteringResults) print measurements.jaccardSim(crossDatasetTrueClassification, clusteringResults) print measurements.NMI(crossDatasetTrueClassification, clusteringResults)
maxIntersection = 0 for cluster in clusteringResults: finalCount = 0 for oracleCluster in LABOMNIDatasetTrueClassification: tempcount = len(set(oracleCluster).intersection(set(cluster))) if finalCount < tempcount: finalCount = tempcount maxIntersection += finalCount print maxIntersection/15.0 fileContainer.write('\n') fileContainer.write('The clustering Jaccard Similarity is : '+ str(maxIntersection/15.0)) tempCCR.append(measurements.ccr(LABOMNIDatasetTrueClassification, clusteringResults)) tempJacardSim.append(measurements.jaccardSim(LABOMNIDatasetTrueClassification, clusteringResults)) tempNMI.append(measurements.NMI(LABOMNIDatasetTrueClassification, clusteringResults)) print measurements.jaccardSim(LABOMNIDatasetTrueClassification, clusteringResults) print measurements.ccr(LABOMNIDatasetTrueClassification, clusteringResults) fileContainer.write('\n') fileContainer.write('The Correct Clustering Rate is : '+ str(measurements.ccr(LABOMNIDatasetTrueClassification, clusteringResults))) fileContainer.write('\n') fileContainer.write('The clustering Jaccard Similarity is : '+ str(measurements.jaccardSim(LABOMNIDatasetTrueClassification, clusteringResults))) print measurements.NMI(LABOMNIDatasetTrueClassification, clusteringResults) fileContainer.write('\nThe NMI is : '+ str(measurements.NMI(LABOMNIDatasetTrueClassification, clusteringResults))) fileContainer.write('\n--------------------------------------------------------------------') fileContainer.write('\n') fileContainer.write(str(tempCCR)) fileContainer.write('\n') fileContainer.write(str(tempJacardSim))