摘要: #中文文本分类 阅读全文
posted @ 2018-12-22 10:48 薛尚 阅读(142) 评论(0) 推荐(0) 编辑
摘要: #导入boston房价数据集 from sklearn.datasets import load_boston import numpy as np boston = load_boston() boston.keys() boston.target import pandas as pd df = pd.DataFrame(boston.data) df from sklearn.line... 阅读全文
posted @ 2018-12-20 14:29 薛尚 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #读取文件text = 'Be assured that individual statistics are not disclosed and this is for internal use only..I am pleased to inform you that you have been 阅读全文
posted @ 2018-12-06 19:41 薛尚 阅读(153) 评论(0) 推荐(0) 编辑
摘要: from sklearn.datasets import load_sample_image china=load_sample_image('china.jpg') print(china.shape) china import matplotlib.pyplot as plt plt.imshow(china) plt.show() plt.imshow(china[... 阅读全文
posted @ 2018-11-15 19:30 薛尚 阅读(245) 评论(0) 推荐(0) 编辑
摘要: #1.用python实现K均值算法 #K-means是一个反复迭代的过程,算法分为四个步骤: import numpy as np x = np.random.randint(1,50,[20,1]) y = np.zeros(20) k = 3 #1) 选取数据空间中的K个对象作为初始中心,每个对象代表一个聚类中心; def initcenter(x,k): return x[:k... 阅读全文
posted @ 2018-11-11 22:16 薛尚 阅读(201) 评论(0) 推荐(0) 编辑
摘要: print("5.取出所有花的花萼长度(cm)的数据------------------------------------------------") #鸢尾花花萼长度的数据 sepal_length=np.array(list(len[0] for len in data['data'])) #一共有150种 print(sepal_length) print("6... 阅读全文
posted @ 2018-11-07 22:51 薛尚 阅读(244) 评论(0) 推荐(0) 编辑
摘要: import numpy from datetime import datetime from Numpy import numSum from Numpy1 import npSum def listSum(n): a = numpy.arange(n) b = numpy.arange(0,5* 阅读全文
posted @ 2018-10-25 20:28 薛尚 阅读(359) 评论(0) 推荐(0) 编辑
摘要: #读取字符串str f = open('zz.txt','r',encoding='utf-8') strbig= f.read() f.close() sep ='''.,;:?!-_''' for ch in sep: strbig = strbig.replace(ch,' ') strbig = strbig.lower() print(strbig) strlist = ... 阅读全文
posted @ 2018-10-18 12:12 薛尚 阅读(259) 评论(0) 推荐(0) 编辑
摘要: #读取fire文本文件 f = open('fire.txt','r',encoding='utf-8') fire = f.read() f.close() print(fire) #预处理 print(fire.lower()) #全部字母小写 a = ",.;:'`" #特殊符号归集为字符串 for b in a: fire.replace(b,' ') #利用for循环... 阅读全文
posted @ 2018-10-12 00:47 薛尚 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 3.解析身份证 4.爬取网址 阅读全文
posted @ 2018-09-10 11:46 薛尚 阅读(173) 评论(0) 推荐(0) 编辑