当前位置:网站首页>Sklearn notes: make_ Blobs generate clustering data
Sklearn notes: make_ Blobs generate clustering data
2022-06-30 01:11:00 【UQI-LIUWJ】
from sklearn.datasets import make_blobs
1 Basic usage
data, label = make_blobs(
n_features=2,
n_samples=100,
centers=3,
random_state=3,
cluster_std=[0.8, 2, 5])2 Parameter description
| n_features | How many eigenvalues does each sample have |
| n_samples | The number of samples |
| centers | Number of cluster centers It can also be a list , Represents each center Corresponding coordinates ( Dimensions and n_features equally ) |
| random_state | Random seeds |
| cluster_std | Variance of each category |
3 Use examples
3.1 centers Is the number
from sklearn.datasets import make_blobs
data, label = make_blobs(n_features=2,
n_samples=100,
centers=2,
random_state=2019,
cluster_std=[0.6,0.7] )
label
'''
array([1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1,
0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0,
1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1,
0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1])
'''
# 100 dimension
data
'''
array([[ 2.42739457, 3.06175875],
[ 7.05586911, -2.34535549],
[ 7.49164297, -2.09940869],
[ 8.95763559, -3.40157028],
[ 2.17353708, 3.06694536],
......
[ 2.29981982, 3.8569118 ]])
'''
#100*2 dimension
import matplotlib.pyplot as plt
colors=['green','blue']
for i,color in enumerate(colors):
color_tmp=np.where(label==i)[0]
plt.scatter(data[color_tmp,0],data[color_tmp,1],c=color,label=i)
plt.legend()
3.2 center It's coordinates
from sklearn.datasets import make_blobs
data, label = make_blobs(n_features=2,
n_samples=100,
centers=[[-100,1],[0,5]],
random_state=2019,
cluster_std=[0.6,0.7]
import matplotlib.pyplot as plt
colors=['green','blue']
for i,color in enumerate(colors):
color_tmp=np.where(label==i)[0]
plt.scatter(data[color_tmp,0],data[color_tmp,1],c=color,label=i)
plt.legend()
边栏推荐
- Cloud, IPv6 and all-optical network
- Quick Pow: 如何快速求幂
- 英伟达Jetson Nano的初步了解
- MES管理系统功能模块之质量管理
- How to view the size of all files in a folder?
- Some thoughts on small program subcontracting and verification of uiniapp subcontracting optimization logic
- MySql函数
- Visual Studio 2017 无法打开包括文件: “QOpenGLFunctions_3_3_Core”: No such file or directory
- MySQL installation steps (detailed)
- How to create a module in the idea and how to delete a module in the idea?
猜你喜欢

Netease cloud music beta music social app "mus" matches friends of the same frequency through music

Understand the module function of MES management system

Online sql to CSV tool

latex如何输入一个矩阵

我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入

Solving plane stress problem with MATLAB

I learned database at station B (V): DQL exercise

2020-12-03

如何在IDEA中自定義模板、快速生成完整的代碼?

数字垃圾是什么?跟随世界第一位AI艺术家,探索元碳艺术
随机推荐
Rubymine development tool, refactoring and intention operation
数字垃圾是什么?跟随世界第一位AI艺术家,探索元碳艺术
How to customize templates and quickly generate complete code in idea?
【three.js】WEB3D初次体验
Live broadcast configuration of crmeb knowledge payment system program configuration (method 2)
MySQL function
HC32M0+ GPIO
Practical application of information security
Mechanical --nx2007 (UG) -- gap analysis (interference inspection)
【Proteus仿真】8比特端口檢測8獨立按鍵
Seata 与三大平台携手编程之夏,百万奖金等你来拿
Netease cloud music beta music social app "mus" matches friends of the same frequency through music
在线文本数字识别列表求和工具
Shell spec date format
SFDP super form development platform v6.0.4 was officially released
STC89C52 single chip microcomputer simple calculator design and code demonstration
How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
Online text digit recognition list summation tool
HC32M0+ GPIO
latex如何输入一个矩阵