当前位置: 首页 > news >正文

网站建设 团队介绍护肤品网站建设分析

网站建设 团队介绍,护肤品网站建设分析,阿里巴巴跨境电商平台,茂名网站建设优化目录 谷歌笔记本#xff08;可选#xff09; 准备数据#xff1a;从文本文件中解析数据 编写算法#xff1a;编写kNN算法 分析数据#xff1a;使用Matplotlib创建散点图 准备数据#xff1a;归一化数值 测试算法#xff1a;作为完整程序验证分类器 使用算法…目录 谷歌笔记本可选 准备数据从文本文件中解析数据 编写算法编写kNN算法 分析数据使用Matplotlib创建散点图 准备数据归一化数值 测试算法作为完整程序验证分类器 使用算法构建完整可用系统 谷歌笔记本可选 from google.colab import drive drive.mount(/content/drive) Mounted at /content/drive 准备数据从文本文件中解析数据 def file2matrix(filename):fr  open(filename)arrayOfLines  fr.readlines()numberOfLines  len(arrayOfLines)returnMat  zeros((numberOfLines, 3))classLabelVector  []index  0for line in arrayOfLines:line  line.strip()listFromLine  line.split(\t)returnMat[index, :]  listFromLine[0:3]classLabelVector.append(int(listFromLine[-1]))index  1return returnMat, classLabelVector datingDataMat, datingLabels  file2matrix(/content/drive/MyDrive/MachineLearning/机器学习/k-近邻算法/使用k-近邻算法改进约会网站的配对效果/datingTestSet2.txt) datingDataMat array([[4.0920000e04, 8.3269760e00, 9.5395200e-01], [1.4488000e04, 7.1534690e00, 1.6739040e00], [2.6052000e04, 1.4418710e00, 8.0512400e-01], ..., [2.6575000e04, 1.0650102e01, 8.6662700e-01], [4.8111000e04, 9.1345280e00, 7.2804500e-01], [4.3757000e04, 7.8826010e00, 1.3324460e00]]) datingLabels[:10] [3, 2, 1, 1, 1, 1, 3, 3, 1, 3] 编写算法编写kNN算法 from numpy import * import operatordef classify0(inX, dataSet, labels, k):dataSetSize  dataSet.shape[0]diffMat  tile(inX, (dataSetSize, 1)) - dataSetsqDiffMat  diffMat ** 2sqDistances  sqDiffMat.sum(axis1)distances  sqDistances**0.5sortedDistIndicies  distances.argsort()classCount  {}for i in range(k):voteIlabel  labels[sortedDistIndicies[i]]classCount[voteIlabel]  classCount.get(voteIlabel, 0)  1sortedClassCount  sorted(classCount.items(), keyoperator.itemgetter(1), reverseTrue)return sortedClassCount[0][0] 分析数据使用Matplotlib创建散点图 import matplotlib import matplotlib.pyplot as plt fig  plt.figure() ax  fig.add_subplot(111) ax.scatter(datingDataMat[:, 1], datingDataMat[:, 2]) plt.show()import matplotlib import matplotlib.pyplot as plt fig  plt.figure() ax  fig.add_subplot(111) ax.scatter(datingDataMat[:, 1], datingDataMat[:, 2],15.0*array(datingLabels), 15.0*array(datingLabels)) plt.show() import matplotlib import matplotlib.pyplot as plt fig  plt.figure() ax  fig.add_subplot(111) ax.scatter(datingDataMat[:, 0], datingDataMat[:, 1],15.0*array(datingLabels), 15.0*array(datingLabels)) plt.show() 准备数据归一化数值 def autoNorm(dataSet):minVals  dataSet.min(0)maxVals  dataSet.max(0)ranges  maxVals - minValsnormDataSet  zeros(shape(dataSet))m  dataSet.shape[0]normDataSet  dataSet - tile(minVals, (m,1))normDataSet  normDataSet/tile(ranges, (m,1))return normDataSet, ranges, minVals normMat, ranges, minVals  autoNorm(datingDataMat) normMat array([[0.44832535, 0.39805139, 0.56233353],[0.15873259, 0.34195467, 0.98724416],[0.28542943, 0.06892523, 0.47449629],...,[0.29115949, 0.50910294, 0.51079493],[0.52711097, 0.43665451, 0.4290048 ],[0.47940793, 0.3768091 , 0.78571804]]) ranges array([9.1273000e04, 2.0919349e01, 1.6943610e00]) minVals array([0. , 0. , 0.001156]) 测试算法作为完整程序验证分类器 def datingClassTest():hoRatio  0.1datingDataMat, datingLabels  file2matrix(/content/drive/MyDrive/MachineLearning/机器学习/k-近邻算法/使用k-近邻算法改进约会网站的配对效果/datingTestSet2.txt)normMat, ranges, minVals  autoNorm(datingDataMat)m  normMat.shape[0]numTestVecs  int(m*hoRatio)errorCount  0for i in range(numTestVecs):classifierResult  classify0(normMat[i,:], normMat[numTestVecs:m,:],datingLabels[numTestVecs:m],3)print(the classifierResult came back with: %d,\the real answer is: %d % (classifierResult, datingLabels[i]))if (classifierResult ! datingLabels[i]):errorCount  1print(the total error rate is: %f % (errorCount/float(numTestVecs))) datingClassTest() the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 3 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 3, the real answer is: 3 the classifierResult came back with: 2, the real answer is: 2 the classifierResult came back with: 1, the real answer is: 1 the classifierResult came back with: 3, the real answer is: 1 the total error rate is: 0.050000 使用算法构建完整可用系统 def classifyPerson():resultList  [not at all,in small doses,in large doses,]percentTats  float(input(percentage of time spent playing video games?))ffMiles  float(input(frequent flier miles earned per year?))iceCream  float(input(liters of ice cream consumed per year?))datingDataMat, datingLabels  file2matrix(/content/drive/MyDrive/MachineLearning/机器学习/k-近邻算法/使用k-近邻算法改进约会网站的配对效果/datingTestSet2.txt)normMat, ranges, minVals  autoNorm(datingDataMat)inArr  array([ffMiles, percentTats, iceCream])classifierResult  classify0((inArr - minVals)/ranges, normMat, datingLabels, 3)print(You will probably like this person:, resultList[classifierResult - 1]) classifyPerson() percentage of time spent playing video games?10 frequent flier miles earned per year?10000 liters of ice cream consumed per year?0.5 You will probably like this person: in small doses
http://www.zqtcl.cn/news/350386/

相关文章:

  • 中国镇江网站如何搭建自己的网址
  • wordpress 自动广告seo搜索引擎优化原理
  • 区块链网站用vue.js做怎么样长春站建筑
  • 集团公司门户网站建设adsl做网站
  • 山东建设监理协会官方网站茂名建站公司模板
  • 烟台做网站案例创业网站推广怎么做
  • php项目网站建设方案书专做药材的网站有哪些
  • 网站表单模板营销型网站建设的5大技巧
  • html手机版网站网站备案后怎么做实名认证
  • 第五冶金建设公司职工大学网站大连工业
  • 网站的基础服务html网站地图生成器
  • 网站开发学徒工作如何设计师培训哪家好
  • 做网站多少钱西宁君博正规株洲在线论坛招聘求职
  • 抚州营销型网站建设殡葬类网站建设
  • 公司网站制作汇报会合肥品牌设计
  • 网站推广策划书怎么说网站建设公司中企动力强
  • php网站源码架构阿里巴巴运营技巧
  • 如何帮助网站吸引流量宁波市网站集约化建设通知
  • 从域名角度看网站建设注意事项河北邯郸seo网站建设网站优化
  • 网站推广策划评估工具7wordpress菜单新连接
  • 网站创建asp电影网站源码
  • 大朗网站建设培训淘宝客cms网站建设
  • 广西建设厅网站在线服务徐州设计网站
  • 重庆营销型网站建设价格网站网站做代理赚钱吗
  • 专门帮做ppt的网站吗网络营销推广的主要特点
  • 烟台做外贸网站店面装修设计图片
  • 广州o2o网站建设餐饮网站建设案例
  • 潜山网站建设抖音代运营报价单
  • 网站建设与推广话术邢台信息港聊天室
  • 获取网页 代码 做网站有哪些网站软件可以做网站的原型