APP下载

基于Python的K—means算法及其应用

2018-01-03薛芯菊

科技视界 2018年24期

薛芯菊

【摘 要】k-means 算法是一种无监督的简单机械学习算法的一种,也是数据挖掘中一个非常有用的聚类分析方法.现在社会中聚类算法对于各个方面分类问题可以进行分析求解求其最优解.本文采用了python这一语言环境进行研究,使用了UCI中的真实数据来进行实验分析.使用python对K-means算法进行编写,通常我们用k-means算法进行运算时K值是规定的,本文使用肘部法则确定其K.有的数据无法直接使用,所以通过pca降维是数据可以更好的展示出来,再通过python编译环境对真实数据进行可视化操作,形成了真实数据和我们所选取的数据的可视化图像。

【关键词】k-means;Python;聚类

中图分类号: TP18 文献标识码: A 文章编号: 2095-2457(2018)24-0141-002

DOI:10.19694/j.cnki.issn2095-2457.2018.24.067

【Abstract】The k-means algorithm is a kind of unsupervised simple mechanical learning algorithm, and it is also a very useful cluster analysis method in data mining. The clustering algorithm implemented by the k-means algorithm in the society can be used in various aspects to analyze the clustering problem and find the optimal solution.This paper uses the python language environment for research, and uses the real data in UCI for experimental analysis. Using python to write K-means algorithm, usually we use the k-means algorithm to calculate the K value is specified, this article uses the elbow rule to determine its K. Some data can not be used directly, so the data can be better displayed through dimensional reduction by pca.

【Key words】Python; K-means; Clustering

聚类分析的算法分为划分法、层次法、基于密度的方法、基于网格的方法、基于模型的方法,并且聚类分析也可以作为数据挖掘算法中其他分析算法的一个预处理步骤[1-2].可以运用数学与计算机的研究模式进行运算,根据数据库中的多条信息进行大致的概括,然后进行区分,分为多个元素一一进行更加深入的研究分析.与K-means算法极为相似的一个算法为K中心算法也是就K-Mediods算法[3],数据挖掘又被人们称为数据库中的知识发现,数据挖掘就是拥有潜在的大量信息价值的重要发觉过程[4].

1 k-means算法

1.1 k-means算法的研究思路

层次法[5]是一种对与给定的数据,进行数据分析处理的一种方法,当我们是用层次法满足我们给定的一些条件时,聚类算法可以进行运行.以下的两种条件……

登录APP查看全文