python机器学习-乳腺癌细胞挖掘(博主亲自录制视频)

https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

生成2类数据

n_features :特征个数= n_informative() + n_redundant + n_repeated
n_informative:多信息特征的个数
n_redundant:冗余信息,informative特征的随机线性组合
n_repeated :重复信息,随机提取n_informative和n_redundant 特征
n_classes:分类类别
n_clusters_per_class :某一个类别是由几个cluster构成的

from sklearn import preprocessing
import numpy as np
#生成分类数据的分类器
from sklearn.datasets.samples_generator import make_classification
#自动生成训练数据和测试数据
from sklearn.cross_validation import train_test_split
#导入支持向量模型
from sklearn.svm import SVC
import matplotlib.pyplot as plt x,y=make_classification(n_samples=300,n_features=2,n_redundant=0,n_informative=2,random_state=22,n_clusters_per_class=1,scale=100) #c=y表示color为黄色
plt.scatter(x[:,0],x[:,1],c=y)
plt.show()

  

生成4类数据

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 7 15:54:56 2018 @author: Administrator
""" from sklearn import preprocessing
import numpy as np
#生成分类数据的分类器
from sklearn.datasets.samples_generator import make_classification
#自动生成训练数据和测试数据
from sklearn.cross_validation import train_test_split
#导入支持向量模型
from sklearn.svm import SVC
import matplotlib.pyplot as plt #n_classes=4生成4类数据
x,y=make_classification(n_classes=4,n_samples=300,n_features=2,n_redundant=0,n_informative=2,random_state=22,n_clusters_per_class=1,scale=100) #c=y表示color为黄色
plt.scatter(x[:,0],x[:,1],c=y)
plt.show()

  

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 7 16:51:38 2018 @author: Administrator
""" import matplotlib.pyplot as plt from sklearn.datasets import make_classification
from sklearn.datasets import make_blobs
from sklearn.datasets import make_gaussian_quantiles
from sklearn.datasets import make_hastie_10_2 plt.figure(figsize=(8, 8))
plt.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95) plt.subplot(421)
plt.title("One informative feature, one cluster per class", fontsize='small')
X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=1,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1) plt.subplot(422)
plt.title("Two informative features, one cluster per class", fontsize='small')
X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1) plt.subplot(423)
plt.title("Two informative features, two clusters per class", fontsize='small')
X2, Y2 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2)
plt.scatter(X2[:, 0], X2[:, 1], marker='o', c=Y2) plt.subplot(424)
plt.title("Multi-class, two informative features, one cluster",
fontsize='small')
X1, Y1 = make_classification(n_samples=1000,n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1, n_classes=3)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1) plt.subplot(425)
plt.title("Three blobs", fontsize='small')
X1, Y1 = make_blobs(n_samples=1000,n_features=2, centers=3)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1) plt.subplot(426)
plt.title("Gaussian divided into four quantiles", fontsize='small')
X1, Y1 = make_gaussian_quantiles(n_samples=1000,n_features=2, n_classes=4)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1) plt.subplot(427)
plt.title("hastie data ", fontsize='small')
X1, Y1 = make_hastie_10_2(n_samples=1000)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
plt.show()

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 7 16:29:35 2018 @author: Administrator
""" import matplotlib.pyplot as plt from sklearn.datasets import make_classification
from sklearn.datasets import make_blobs
from sklearn.datasets import make_gaussian_quantiles
from sklearn.datasets import make_hastie_10_2 #画布的大小为长20cm高20cm
plt.figure(figsize=(15,10)) #标题,fontsize为标题字体大小
plt.title("Gaussian divided into six quantiles", fontsize='large')
X1, Y1 = make_gaussian_quantiles(n_samples=1000,n_features=2, n_classes=6) #绘制点,X1[:, 0]为点的x列表值, X1[:, 1]为点的y列表值, c=Y1表示颜色,c为color缩写
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)

  

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 7 16:51:38 2018 @author: Administrator
""" from sklearn.datasets import make_circles
from sklearn.datasets import make_moons
import matplotlib.pyplot as plt
import numpy as np #画布的大小为长20cm高20cm
plt.figure(figsize=(15,10)) fig=plt.figure(1)
x1,y1=make_circles(n_samples=1000,factor=0.5,noise=0.1)
plt.subplot(121)
plt.title('make_circles function example')
plt.scatter(x1[:,0],x1[:,1],marker='o',c=y1) plt.subplot(122)
x1,y1=make_moons(n_samples=1000,noise=0.1)
plt.title('make_moons function example')
plt.scatter(x1[:,0],x1[:,1],marker='o',c=y1)
plt.show()

  

 https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章)

 

sklearn6_生成分类数据的更多相关文章

  1. Python之机器学习-sklearn生成随机数据

    sklearn-生成随机数据 import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotli ...

  2. 无限级分类及生成json数据

    第一步,先去数据库查询类别数据,然后交给生成json数据的函数处理,代码如下: /*生成类别JSON数据*/ public function wirteJson(){ $dataInfo = \thi ...

  3. SAP QA32 做使用决策系统报错:分类数据的不一致性=>交易终止

    SAP QA32 做使用决策系统报错:分类数据的不一致性=>交易终止 QA32,对如下检验批做处理,系统报错, 试图使用MSC3N去显示这个批次主数据,同样报错, 原因在于批次的分类数据产生后, ...

  4. flask实战-个人博客-数据库-生成虚拟数据 --

    3.生成虚拟数据 为了方便编写程序前台和后台功能,我们在创建数据库模型后就编写生成虚拟数据的函数. 1)管理员 用于生成虚拟管理员信息的fake_admin()函数如下所示: personalBlog ...

  5. Enterprise Solution 生成实体数据访问接口与实现类型 Code Smith 6.5 模板文件下载

    数据库表定义为SalesOrder,用LLBL Gen Pro生成的实体定义是SalesOrderEntity,再用Code Smith生成的数据读写接口是ISalesOrderManager,最后是 ...

  6. 改用C++生成自动化数据表

    改用C++生成自动化数据表 前面的文章中,我们讨论了使用一个基于.NET的第三方程序库来从程序中来生成数据表.在我看来,这整个思路是非常有用的,例如为显示测试结果.我经常会自己在博客中尝试各种像这样的 ...

  7. SQL Server中公用表表达式 CTE 递归的生成帮助数据,以及递归的典型应用

    本文出处:http://www.cnblogs.com/wy123/p/5960825.html 我们在做开发的时候,有时候会需要一些帮助数据,必须需要连续的数字,连续间隔的时间点,连续的季度日期等等 ...

  8. 公用表表达式(CTE)递归的生成帮助数据

    本文的作者辛苦了,版权问题特声明本文出处:http://www.cnblogs.com/wy123/p/5960825.html 工作有时候会需要一些帮助数据,必须需要连续的数字,连续间隔的时间点,连 ...

  9. TreeView递归绑定无限分类数据

    TreeView递归绑定无限分类数据 实现一个动态绑定,无限级分类数据时,需要将数据绑定到TreeView控件,分类表的结构是这样的: 字段 类型 Id int ParentId int Name N ...

随机推荐

  1. [BZOJ2138]stone[霍尔定理+线段树]

    题意 一共有 \(n\) 堆石子,每堆石子有一个数量 \(a\) ,你要进行 \(m\) 次操作,每次操作你可以在满足前 \(i-1\) 次操作的回答的基础上选择在 \([L_i,R_i]\) 区间中 ...

  2. PowerBI开发 第十三篇:增量刷新

    PowerBI 将要解锁增量刷新(Incremental refresh)功能,这是一个令人期待的更新,使得PowerBI可以加载大数据集,并能减少数据的刷新时间和资源消耗,该功能目前处于预览状态,只 ...

  3. grunt-inline:一个资源内嵌插件

    一.插件简介 将引用的外部资源,如js.css.img等,内嵌到引用它们的文件里去. 二.使用场景 在项目中,出于某些原因,有的时候我们需要将一些资源,比如js脚本内嵌到页面中去.比如我们的html页 ...

  4. 杂谈---LZ的编程之路以及十点建议

    LZ本人是09年毕业的,在某二流本科院校学的非计算机专业,在兴趣的驱使之下,最终毅然决然的走上了编程这一条“不归路”. 说起LZ的经历虽不算是跌宕起伏,但也真正算是人生无常. 当初09年7月回到家里, ...

  5. 阿里云容器服务区块链解决方案全新升级 支持Hyperledger Fabric v1.1

    摘要: 全球开源区块链领域影响最为广泛的Hyperledger Fabric日前宣布了1.1版本的正式发布,带来了一系列丰富的新功能以及在安全性.性能与扩展性等方面的显著提升.阿里云容器服务区块链解决 ...

  6. 机房ping监控 smokeping+prometheus+grafana

    一.前言 1.本监控方案主要由smokeping+promethues+grafana组成.smokeping主要数据采集,promethues作为数据存储,grafana数据展示 2.其实smoke ...

  7. PHPMyWind5.4存储XSS(CVE-2017-12984)

    0x0 环境 操作机:xp   192.168.110.128 目标:win2003    192.168.110.133 目标cms:PHPMyWind5.4 0x11 漏洞介绍 允许恶意访问者在客 ...

  8. Scrum Meeting NO.2

    Scrum Meeting No.2 1.会议内容 今天,我们对已经确定的任务进行了分配,并针对界面设计方面的细节进行讨论. 由于这周其它课程任务繁重(编译+数据库).前端的任务主要分配给编程能力较好 ...

  9. 读C#程序(第三周)

    阅读下面程序,请回答如下问题: 问题1:这个程序要找的是符合什么条件的数? 问题2:这样的数存在么?符合这一条件的最小的数是什么? 问题3:在电脑上运行这一程序,你估计多长时间才能输出第一个结果?时间 ...

  10. 以webService为客户端获取List泛型结果集

    首先搭建好webService,添加XFire1.2Core Libraries 和XFire1.2HTTP Client Libraries,连接上数据库,下例以oracle为数据库. 连接Oral ...