生成随机产生的训练数据
来源:互联网 发布:计算机二进制算法 编辑:程序博客网 时间:2024/06/05 02:52
生成随机产生的训练数据#createDist.pyfrom numpy import *import matplotlibimport matplotlib.pyplot as pltfrom matplotlib.patches import Rectanglen = 1000 #number of points to createxcord = zeros((n))#create a shuzu,length=nycord = zeros((n))markers =[]#used to give different date with different sizecolors =[]#used to give different date with different colorfw = open('testSet.txt','w')#open a file in a write wayfor i in range(n):#give n=1000 date diferent value [r0,r1] = random.standard_normal(2)#create a list whitch has two elements myClass = random.uniform(0,1)#used to classify if (myClass <= 0.16): fFlyer = random.uniform(22000, 60000) tats = 3 + 1.6*r1 markers.append(20) colors.append(2.1) classLabel = 1 #'didntLike' print (("%d, %f, class1") % (fFlyer, tats)) elif ((myClass > 0.16) and (myClass <= 0.33)): fFlyer = 6000*r0 + 70000 tats = 10 + 3*r1 + 2*r0 markers.append(20) colors.append(1.1) classLabel = 1 #'didntLike' print (("%d, %f, class1") % (fFlyer, tats)) elif ((myClass > 0.33) and (myClass <= 0.66)): fFlyer = 5000*r0 + 10000 tats = 3 + 2.8*r1 markers.append(30) colors.append(1.1) classLabel = 2 #'smallDoses' print (("%d, %f, class2") % (fFlyer, tats)) else: fFlyer = 10000*r0 + 35000 tats = 10 + 2.0*r1 markers.append(50) colors.append(0.1) classLabel = 3 #'largeDoses' print (("%d, %f, class3") % (fFlyer, tats)) if (tats < 0): tats =0 if (fFlyer < 0): fFlyer =0 xcord[i] = fFlyer; ycord[i]=tats fw.write("%d\t%f\t%f\t%d\n" % (fFlyer, tats, random.uniform(0.0, 1.7), classLabel))#put the value in a filefw.close()#close the opend filefig = plt.figure()#make one figureax = fig.add_subplot(2,1,1)#the part of the figuretype1 = ax.scatter([-10000], [-10], s=20, c='red')#make a scater picture,s=size,c=color,whitch can be iterable maker='o'type2 = ax.scatter([-10000], [-15], s=30, c='green')type3 = ax.scatter([-10000], [-20], s=5, c='black')ax.legend([type1, type2, type3], ["Class 1", "Class 2", "Class 3"], loc=2)#ax=fig.add_subplot(2,1,2)#the sencond part of the figureax.scatter(xcord,ycord, c=colors, s=markers)#x,y,color,size,all of them can be iterable#ax.axis([-5000,100000,-2,25])plt.xlabel('Frequent Flyier Miles Earned Per Year')plt.ylabel('Percentage of Body Covered By Tatoos')plt.show()
阅读全文
0 0
- 生成随机产生的训练数据
- 随机数据产生的问题
- .NET(C#)生成随机姓名,随机汉字的产生
- 随机数的产生--随机文本串的生成
- php生成随机产生六位数密码的代码
- javaweb注册的时候产生随机图片并且生成随机数
- 随机生成数据 文件数据的输入输出
- 利用均匀分布产生随机的正态分布的数据输入源
- 产生随机的数组
- 产生随机的字符串
- 问题 H C.产生均匀分布的随机数据
- caffe训练中create image数据产生的bug
- 表达式生成满足条件的随机数据
- 随机生成不重复的数据
- Oracle插入随机生成的数据行
- 机器学习算法的随机数据生成
- 常见的随机数据生成方法
- matlab生成随机数据
- Centos7安装Redis
- opencv3.3.0载入本地图片和网络图片新解
- [强化学习]区分Model-free和Model-based方法
- 通过监听器调起新线程执行扫描任务
- 如何用python的画几组数据量不同的boxplot(箱线图)
- 生成随机产生的训练数据
- 计算机组成原理实验三:二进制补码加法器
- HYSBZ2595-游览计划(斯坦纳树)
- 取文本值
- 插入排序之希尔排序
- java学习第47天,创建 删除 文件 目录 多级目录
- Spring对Session共享的管理(1)-----SpringSession的优点
- putty连接阿里云服务器 ECS
- 利用栈检测括号的配对情况