# 3维
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets.samples_generator import make_classification
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
data,labels=make_classification(n_samples=1000,n_features=3,n_redundant=0,n_informative=2,
random_state=1,n_clusters_per_class=2) unique_lables=set(labels)
colors=plt.cm.Spectral(np.linspace(0,1,len(unique_lables)))
for k,col in zip(unique_lables,colors):
x_k=data[labels==k]
ax.scatter3D(x_k[:,0],x_k[:,1],x_k[:, 2], c=col) # 开始绘制,x_k[:,0] 表示取第一维 plt.title('data by make_classification()')
plt.show()
# 2维

import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets.samples_generator import make_classification
data,labels=make_classification(n_samples=100,n_features=2,n_redundant=0,n_informative=2,
random_state=5,n_clusters_per_class=2)
unique_lables=set(labels)
colors=plt.cm.Spectral(np.linspace(0,1,len(unique_lables)))
for k,col in zip(unique_lables,colors):
x_k=data[labels==k]
plt.plot(x_k[:,0],x_k[:,1],'o',markerfacecolor=col,markeredgecolor="k",
markersize=10)
plt.title('data by make_classification()')
plt.show()

最新文章

  1. Javascript对象创建
  2. ASM:《X86汇编语言-从实模式到保护模式》第13章:保护模式下内核的加载,程序的动态加载和执行
  3. codeforces 336C Vasily the Bear and Sequence(贪心)
  4. python基础===使用switch方法,减少使用if语句
  5. [转]ORACLE SQL解析之硬解析和软解析
  6. R语言︱异常值检验、离群点分析、异常值处理
  7. Metaphor of quotient space
  8. .Net Excel 导出图表Demo(柱状图,多标签页)
  9. centos docker 安装
  10. 22 python 初学(类,面向对象)
  11. 倒水问题(Fill, UVa 10603)
  12. git使用——分支
  13. ssh 设置反向代理
  14. hadoop之计数器和管道的mrunit测试
  15. img图片自适应宽和高[转]
  16. 【leetcode】198.HouseRobber
  17. 42.Trapping Rain Water---dp,stack,两指针
  18. $FFT$(快速傅里叶变换)
  19. 资产证券化(ABS)+ 特殊目的信托(SPV)
  20. Mysql数据操作《二》单表查询

热门文章

  1. Hibernate中OpenSessionInViewFilter(通常配置在web.xml文件中)的作用
  2. Spring 配置 事务的几种方式
  3. Java代码优化(一)
  4. Failed to get D-Bus connection: Operation not permitted
  5. python 几种方法实现随机生成8位同时包含数字、大写字符、小写字符密码的小程序
  6. sql 中如何查询某一列的数据在另一个表中有没有?
  7. c#使用NPOI快速导出到Excel
  8. 浏览器对HTTP请求的编码行为
  9. 【cocos2d-x 手游研发----精灵的八面玲珑】
  10. android界面