博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kmeans算法初步
阅读量:2388 次
发布时间:2019-05-10

本文共 1184 字,大约阅读时间需要 3 分钟。

# -*- coding: utf-8 -*-"""Created on Tue Mar 26 09:11:21 2019@author: hadron"""from sklearn.datasets import make_blobsimport matplotlib.pyplot as pltif __name__ == '__main__':    N = 400    centers = 4    '''    make_blobs函数是为聚类产生一个数据集和相应的标签    n_samples:表示数据样本点个数,默认值100    n_features:表示数据的维度,默认值是2    centers:产生数据的中心点,默认值3    cluster_std:数据集的标准差,浮点数或者浮点数序列,默认值1.0    center_box:中心确定之后的数据边界,默认值(-10.0, 10.0)    shuffle :洗乱,默认值是True    random_state:官网解释是随机生成器的种子    返回值说明:    (1) X : array of shape [n_samples, n_features],The generated samples.生成的样本数据集。    (1) y : array of shape [n_samples],The integer labels for cluster membership of each sample.样本数据集的标签。    '''    # 生成400个2维样本点集合,中心点4个    data, y = make_blobs(n_samples=N, n_features=2, centers=centers)    '''    matplotlib.pyplot.scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, data=None, **kwargs)    参数说明:    (1)x,y:表示的是大小为(n,)的数组,也就是我们即将绘制散点图的数据点    (2)c:表示的是颜色,也是一个可选项。默认是蓝色'b',表示的是标记的颜色,或者可以是一个表示颜色的字符,或者是一个长度为n的表示颜色的序列等等    '''    #利用pyplot模块的scatter函数绘制散点图    plt.scatter(data[:, 0], data[:, 1], c=y)    plt.show()

运行结果

在这里插入图片描述

转载地址:http://igvab.baihongyu.com/

你可能感兴趣的文章
WASC Distributed Web Honeypots Project Update
查看>>
安装pydev到eclipse
查看>>
[WAF]apache和modsecurity的安装
查看>>
写给换工作和找工作的同学
查看>>
Island Hopping the SpiderLabs Way
查看>>
Top Ten Web Protection Techniques of 2011
查看>>
Faster Blind MySQL Injection Using Bit Shifting
查看>>
Safely Dumping Hashes from Live Domain Controllers
查看>>
PHP CGI Argument Injection
查看>>
sgx模拟器
查看>>
SGX相关资源
查看>>
nessus 购买地址
查看>>
Google Security Architecture
查看>>
web server信息收集(附带plesk xday)
查看>>
JBoss AS Administrative Console Password Disclosure
查看>>
Securely Developing on Mobile
查看>>
ModSecurity Updates: Nginx Stable Release and Google Summer of Code Participation
查看>>
Ubuntu 12.04 Precise LTS: Install ModSecurity for Apache 2 web server
查看>>
Java Web 三层架构详解
查看>>
iphone for PPT遥控器 MyPoint PowerPoint Remote
查看>>