# coding: utf-8
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.cluster import KMeans
#聚类数据准备,字符串矩阵
corpus=[]
titles=[]
with open(r"D:\Neo4j\know——get\pyltp_jufafenxi\quchogfu.txt",encoding="utf-8") as fr:
for lin in fr:
if "SOL" not in lin and "O O" not in lin and "I-SOL" not in lin:
lin=lin.replace("{","")
lin = lin.replace("'SOL'", "")
lin = lin.replace(":"
对文本kmeans聚类,TF-IDF词频统计,TSNE降维数画散点图显示聚类结果
最新推荐文章于 2024-09-30 06:30:00 发布
本文介绍了如何运用TF-IDF进行文本词频统计,并结合k-means聚类算法进行文本分类。接着,通过TSNE降维技术将高维聚类结果转化为二维空间,绘制散点图以直观展示聚类效果。
摘要由CSDN通过智能技术生成