2018年12月24日

完整的中英文词频统计

摘要: for word in sep: str=str.replace(word,"") print(str) #排除无意义的词 li=str.split() strset=set(li) exclude={'in','you','i','go'} strset=strset-exclude #单词字数 dict={} f... 阅读全文

posted @ 2018-12-24 10:47 zoyeln 阅读(166) 评论(0) 推荐(0) 编辑

聚类--K均值算法:自主实现与sklearn.cluster.KMeans调用

摘要: import numpy as np x = np.random.randint(1,50,[20,1]) y = np.zeros(20) k = 3 #1) 选取数据空间中的K个对象作为初始中心,每个对象代表一个聚类中心; def initcen(x,k): return x[:k] #2) 对于样本中的数据对象,根据它们与这些聚类中心的欧氏距离,按距离最近的准则将它们分到距离它们最... 阅读全文

posted @ 2018-12-24 10:43 zoyeln 阅读(225) 评论(0) 推荐(0) 编辑

期末大作业

摘要: import jieba path=r'"E:\中文数据清理\147\"' with open(r'E:\中文数据清理\stopsCN.txt',encoding='utf-8')as f: stopword=f.read().split('\n') List01=[] List02=[] def read_text(name,start,end): for fi... 阅读全文

posted @ 2018-12-24 08:28 zoyeln 阅读(175) 评论(0) 推荐(0) 编辑

导航