def SpectralAccuracy():
clusterer = SpectralClustering(n_clusters=2)
tdm = pickle.load(open(DATASET_PATH + "BOW_TDIDF.p", "rb"))
predictions = clusterer.fit_predict(tdm)
true_labels = pickle.load(open(OUTFILE_STANCE, "rb"))[0]
numerical_mapped_1 = [0 if i == "Israeli" else 1 for i in true_labels]
numerical_mapped_2 = [1 if i == "Israeli" else 0 for i in true_labels]
one = f1_score(numerical_mapped_1, predictions)
two = f1_score(numerical_mapped_2, predictions)
print("The F1 score of Spectral Clustering on BOW (w/Tdidf) is: " + str(max(one, two)))
评论列表
文章目录