上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 29 下一页
摘要: 结果: 阅读全文
posted @ 2019-04-08 19:01 山…隹 阅读(200) 评论(0) 推荐(0)
摘要: import re import numpy as np def file_do(filename): with open(filename,'rb') as f: data = f.read().decode() data = data.split('\n') # print('dasdqaw:',data) words = [] ... 阅读全文
posted @ 2019-04-04 16:18 山…隹 阅读(610) 评论(0) 推荐(0)
摘要: import numpy as np import math #加载模拟数据 def loaddata(): postingList=[['my','dog','has','flea','problem','help','please'], ['maybe','not','take','him','to','dog','park','stupid'],... 阅读全文
posted @ 2019-04-03 22:45 山…隹 阅读(485) 评论(0) 推荐(0)
摘要: def classfify(mytree,testdata,labels): # print('mytree:{},testdata:{},labels:{}'.format(mytree,testdata,labels)) firststr = list(mytree.keys())[0] #树中的第一个keys值获取,即第一个特征值名称 ... 阅读全文
posted @ 2019-04-01 17:09 山…隹 阅读(704) 评论(0) 推荐(0)
摘要: import numpy as np import math #产生数据的函数 def createdatabase(): dataSet = [[1,1,'yes'],[1,1,'yes'],[1,0,'no'],[0,1,'no'],[0,1,'no']] labels = [['no surfacing'],['flippers']] return dataSet... 阅读全文
posted @ 2019-03-30 15:02 山…隹 阅读(633) 评论(0) 推荐(0)
摘要: #归一化数值 防止特征值权值过大 方法:newdata = (olddata - min)/(max - min) a = np.array([[1,0.1,7],[1.5,0.1,2],[1.6,0.4,3],[1.2,0.4,4],[1.3,0.5,12]]) # a # [[ 1. 0.1 7. ] # [ 1.5 0.1 ... 阅读全文
posted @ 2019-03-26 22:25 山…隹 阅读(163) 评论(0) 推荐(0)
摘要: a = np.arange(0,20,1) b = np.array([1,1,2,3,4,3,2,1,2,3,4,5,1,2,3,2,2,1,1,3]) print(len(b)) fig = plt.figure() #创建一个figure图对象 ax1 = fig.add_subplot(221) #创建一个2行2列4个子... 阅读全文
posted @ 2019-03-26 18:48 山…隹 阅读(158) 评论(0) 推荐(0)
摘要: # # kNN 分类算法 a = np.array([[1,1],[1.2,1.5],[0.3,0.4],[0.2,0.5]]) #构造样本数据 labels = ['A','A','B','B'] # print(a.shape[0]) # 行数 shape(1)表示列数 diffMat = np.tile (np.array([[1.5,1.2... 阅读全文
posted @ 2019-03-26 13:09 山…隹 阅读(143) 评论(0) 推荐(0)
摘要: mport numpy as np #数据包 import scipy from scipy import stats import matplotlib as mpl import matplotlib.pyplot as plt #画图 # # 1. 数据的形成 x = np.arange(0,51,10).reshape((-1,1)) # b # [[... 阅读全文
posted @ 2019-03-26 13:07 山…隹 阅读(190) 评论(0) 推荐(0)
摘要: 需要稍作解释的就是write_merge方法: write_merge(x, x + m, y, w + n, string, sytle)x表示行,y表示列,m表示跨行个数,n表示跨列个数,string表示要写入的单元格内容,style表示单元格样式。其中,x,y,w,h,都是以0开始计算 的。 阅读全文
posted @ 2019-03-21 17:04 山…隹 阅读(582) 评论(0) 推荐(0)
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 29 下一页