摘要: 一. #导入os包加载数据目录import ospath = r'F:\迅雷下载\258'#停词库with open(r'F:\迅雷下载\stopsCN.txt', encoding='utf-8') as f: stopwords = f.read().split('\n') #对数据进行标准编码 阅读全文
posted @ 2018-12-23 22:03 cjh陈 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #导入邮件数据 1 2 3 4 5 6 7 8 9 10 11 import csv file_path=r'F:\Pycharm\11.22\SMSSpamCollection' sms=open(file_path,'r',encoding='utf-8') sms_data=[] sms_la 阅读全文
posted @ 2018-12-06 21:52 cjh陈 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1.算法from sklearn.datasets import load_iris iris =load_iris() iris.keys() from sklearn.cluster import KMeans est = KMeans(n_clusters=4) est.fit(iris.data) est.labels_ iris.target from sklearn.... 阅读全文
posted @ 2018-11-22 21:50 cjh陈 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 1.观察图片变化 from sklearn.datasets import load_sample_image import matplotlib.pyplot as plt from sklearn.cluster import KMeans import numpy as np flower=l 阅读全文
posted @ 2018-11-15 22:18 cjh陈 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 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-11-11 23:55 cjh陈 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 运行结果: 阅读全文
posted @ 2018-11-05 08:53 cjh陈 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1、处理日期时间 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import datetime print(datetime.datetime.now()) print(" ") from datetime import datetime,ti 阅读全文
posted @ 2018-10-22 11:34 cjh陈 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 中英文统计 1. 2. 中文统计 阅读全文
posted @ 2018-10-19 21:17 cjh陈 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1. 2. 阅读全文
posted @ 2018-10-10 22:17 cjh陈 阅读(125) 评论(0) 推荐(0) 编辑
摘要: def Sum(n): #定义一个函数(注意:格式对齐,否则会出错) a=list(range(n)) b=list(range(0,50000*n,5)) c=[] for i in range(len(a)): c.append(a[i]**2+b[i]**3) return c print(Sum(20)) imp... 阅读全文
posted @ 2018-10-02 20:01 cjh陈 阅读(102) 评论(0) 推荐(0) 编辑