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A/EDAAAQPJAzAAAACQPxAwAAEDyQMwAAAAkD8QMAABA8kDMAAAAJA/EDAAAQPJAzAAAACQPxAwAAEDyQMwAAAAkD8QMAABA8kDMAAAAJA/EDAAAQPJAzAAAACQPxAwAAEDy/D8K31VFWPB93AAAAABJRU5ErkJggg==" alt="" width="782" height="392" />

分为两个类kMeans和pointClass类,kMeans两个成员变量:节点总个数和最终聚类个数。pointClass类包含结构体point。

具体代码如下:

kMeans.h

class kMeans{
protected:
int numOfPoint, numOfCenter;
public:
kMeans();
void k_means();
};

kMeans.cpp

#include "kMeans.h"
#include "point.h"
#include <iostream>
using namespace std; kMeans::kMeans()
{
cout << "分别输入数据点和最终聚类的个数: ";
cin >> numOfPoint >> numOfCenter;
} void kMeans::k_means()
{
pointClass pc(numOfPoint, numOfCenter);
pc.InitCenter(numOfPoint, numOfCenter);
bool b = true;
while (b){
pc.setPoint(numOfPoint, numOfCenter);
if (pc.getError()){
break;
}
pc.getNewCenter(numOfPoint, numOfCenter);
b = pc.IsEnd(numOfCenter);
pc.resetCenterOld(numOfCenter);
}
if (b) {
cout << "聚类操作无法完成!!" << endl;
}else{
pc.ExportData(numOfPoint, numOfCenter);
}
}

point.h

struct point{
double x1, x2, x3, x4;
int flag;
}; class pointClass{
protected:
double errorOld, errorNew;
point *pList, *centerListNew, *centerListOld;
double GetDistance(point point1, point point2);
bool GetExist(int xm, int centerList[], int n);
public:
pointClass (int numOfPoint, int numOfCenter);
void InitCenter (int numOfPoint, int numOfCenter);
void setPoint (int numOfPoint, int numOfCenter);
bool getError();
void getNewCenter (int numOfPoint, int numOfCenter);
bool IsEnd (int numOfCenter);
void ExportData (int numOfPoint, int numOfCenter);
void resetCenterOld (int numOfCenter);
~pointClass ();
};

point.cpp

#include <iostream>
#include <fstream>
#include <cmath>
#include <ctime>
#include "point.h"
using namespace std; double pointClass::GetDistance(point point1, point point2)
{
return pow(pow(point1.x1 - point2.x1, ) + pow(point1.x2 - point2.x2, ) + pow(point1.x3 - point2.x3, ) + pow(point1.x4 - point2.x4, ), 0.5);
} bool pointClass::GetExist(int xm, int CentIndex[], int n)
{
bool b = false;
for (int i = ; i < n; i++){
if (xm == CentIndex[i]){
b = true;
break;
}
}
return b;
} pointClass::pointClass(int numOfPoint, int numOfCenter)
{
pList = new point[numOfPoint];
centerListOld = new point[numOfCenter];
centerListNew = new point[numOfCenter];
ifstream ifile("D:\\IrisData.txt");
if (!ifile.is_open()){
cerr << "file" << endl;
exit();
}
int i = ;
while (i < numOfPoint){
ifile >> pList[i].x1 >> pList[i].x2 >> pList[i].x3 >> pList[i].x4;
pList[i].flag = ;
i++;
}
ifile.close(); errorNew = , errorOld = ;
for (i = ; i < numOfCenter; i++){
centerListOld[i].x1 = ;
centerListOld[i].x2 = ;
centerListOld[i].x3 = ;
centerListOld[i].x4 = ;
centerListNew[i].x1 = ;
centerListNew[i].x2 = ;
centerListNew[i].x3 = ;
centerListNew[i].x4 = ;
centerListNew[i].flag = ;
centerListOld[i].flag = ;
}
} void pointClass::InitCenter(int numOfPoint, int numOfCenter)
{
int xm, i;
int *CenterIndex = new int[numOfCenter];
srand((unsigned)time());
for (i = ; i < numOfCenter; i++){
do {
xm = rand() % numOfPoint;
} while (GetExist(xm, CenterIndex, i));
CenterIndex[i] = xm;
} for (i = ; i < numOfCenter; i++){
centerListOld[i] = pList[CenterIndex[i]];
}
} void pointClass::setPoint(int numOfPoint, int numOfCenter)
{
errorNew = ;
for (int i = ; i < numOfPoint; i++){
int flagi = ;
double distance = GetDistance(pList[i], centerListOld[]);
for (int j = ; j < numOfCenter; j++){
double tmp = GetDistance(pList[i], centerListOld[j]);
if (tmp < distance){
tmp = distance;
flagi = j;
}
}
pList[i].flag = flagi;
errorNew = GetDistance(pList[i], centerListOld[flagi]);
}
} bool pointClass::getError()
{
bool b = false;
if (errorOld != && errorNew >= errorOld){
b = true;
}
return b;
} void pointClass::getNewCenter(int numOfPoint, int numOfCenter)
{
for (int i = ; i < numOfCenter; i++){
centerListNew[i].x1 = ;
centerListNew[i].x2 = ;
centerListNew[i].x3 = ;
centerListNew[i].x4 = ;
centerListNew[i].flag = ;
}
for (int i = ; i < numOfPoint; i++){
centerListNew[pList[i].flag].x1 += pList[i].x1;
centerListNew[pList[i].flag].x2 += pList[i].x2;
centerListNew[pList[i].flag].x3 += pList[i].x3;
centerListNew[pList[i].flag].x4 += pList[i].x4;
centerListNew[pList[i].flag].flag++;
}
for (int i = ; i < numOfCenter; i++){
centerListNew[i].x1 = centerListNew[i].x1 / centerListNew[i].flag;
centerListNew[i].x2 = centerListNew[i].x2 / centerListNew[i].flag;
centerListNew[i].x3 = centerListNew[i].x3 / centerListNew[i].flag;
centerListNew[i].x4 = centerListNew[i].x4 / centerListNew[i].flag;
centerListNew[i].flag = ;
}
} void pointClass::resetCenterOld(int numOfCenter)
{
for (int i = ; i < numOfCenter; i++){
centerListOld[i] = centerListNew[i];
}
} bool pointClass::IsEnd(int numOfCenter)
{
bool b = false;
for (int i = ; i < numOfCenter; i++){
if (GetDistance(centerListNew[i],centerListOld[i]) > ){
b = true;
break;
}
}
return b;
} void pointClass::ExportData(int numOfPoint, int numOfCenter)
{
ofstream ofile("D:\\kMeansResult.txt");
cout << "本次误差是:" << errorNew << endl;
ofile << "本次误差是:" << errorNew << endl;
for (int j = ; j < numOfCenter; j++){
ofile << "第" << j+ <<"类:" << endl;
for (int i = ; i < numOfPoint; i++){
if (pList[i].flag == j){
ofile << pList[i].x1 << " " << pList[i].x2 << " " << pList[i].x3 << " " <<pList[i].x4 << endl;
}
}
}
} pointClass::~pointClass()
{
delete[] pList;
delete[] centerListOld;
delete[] centerListNew;
}

主函数main.cpp

#include <iostream>
#include "kMeans.h"
using namespace std; int main()
{
kMeans km;
km.k_means();
return ;
}

k_means算法C++实现,改为面向对象的更多相关文章

  1. k_means算法的C++实现

    首先画出k_means算法的流程图:

  2. k_means算法+python实现

    文章目录 一.原理 二.算法步骤 三.实例如下: 四.python代码实现: 一.原理 K均值算法使用的聚类准则函数是误差平方和准则,通过反复迭代优化聚类结果,使所有样本到各自所属类别的中心的距离平方 ...

  3. JAVA学习:面向对象编程

    "算法+数据结构=程序"是一句经典名言,这句话很直接的说明了程序的本质:处理数据.产生结果.即便是最简单的HelloWorld程序,我们也可以将字符串"HelloWorl ...

  4. Java数据结构和算法 - 数组

    Q: 数组的创建? A: Java中有两种数据类型,基本类型和对象类型,在许多编程语言中(甚至面向对象语言C++),数组也是基本类型.但在Java中把数组当做对象来看.因此在创建数组时,必须使用new ...

  5. js面向对象

    什么事面向对象 用对象的思想去写代码,就是面向对象编程 面向对象编程(OOP)的特点 抽象:抓住核心问题 封装:只能通过对象来访问方法 继承:从已有对象上继承出新的对象 多态:多对象的不同形态 对象的 ...

  6. 面向过程 vs 面向对象

    从网上摘录了一些面向过程vs.面向对象的分析,先简单记录如下,稍后会继续整理. 为什么会出现面向对象分析方法? 因为现实世界太复杂多变,面向过程的分析方法无法实现. 面向过程 采用面向过程必须了解整个 ...

  7. JavaScript 面向对象(二) —— 案例篇

    看案例前可以先看看基础篇:JavaScript 面向对象(一) —— 基础篇 案例——面向对象的选项卡:把面向过程的程序一步步改成面向对象的形式,使其能够更加的通用(但是通用的东西,一般会比较臃肿). ...

  8. JAVA的面向对象编程--------课堂笔记

    面向对象主要针对面向过程. 面向过程的基本单元是函数.   什么是对象:EVERYTHING IS OBJECT(万物皆对象)   所有的事物都有两个方面: 有什么(属性):用来描述对象. 能够做什么 ...

  9. 【转】三十分钟学会STL算法

    转载自: http://net.pku.edu.cn/~yhf/UsingSTL.htm 这是本小人书.原名是<using stl>,不知道是谁写的.不过我倒觉得很有趣,所以化了两个晚上把 ...

随机推荐

  1. //todo 的用处

    在代码中添加 //todo 以后要做的事 可以暂时打上标记,以后再来处理. 光有这个没什么用,关键是IDE要支持,比如VS2017,只要按下 ctrl+w,t 就可以在输出窗口中显示出所有 todo的 ...

  2. Symfony 2.0 认识Request, Response, Session, Cookie

    在上一节中,我们提到了如何创建一个Bunlde 并且在默认控制器中添加一些方法.如果有参照之前的说法进行的话,读者很有可能会被提示说 返回的Response对象不能为空.好啦,我们就来研究一下,怎么从 ...

  3. 向ArcGIS的ToolBarControl中添加任意的windows组建的方法[转]

    向ArcGIS的ToolBarControl中添加任意的windows组建的方法[转] Link: http://www.cnblogs.com/mymhj/archive/2012/10/12/27 ...

  4. 若p是与10互质的质数,则p-1个9能被p整除

    [若p是与10互质的质数,则k(p-1)个9能被p整除] 因为(p,10)=1,所以(p,10^k)=1.根据费马定理,10^(k*(p-1))-1|p. 而10^k*(p-1)-1是一个位数为(p- ...

  5. 根据车辆品牌获取品牌所属公司,车标logo,创建年份等基本信息

    接口:http://api.besttool.cn/?c=Car&a=brand 请求方式:post 参数: appid 请联系博主QQ987332767获取,注明车标接口,测试appid: ...

  6. 利用WKWebView实现js与OC交互注意事项

    最近在写一些关于wkwebview的一些代码,发现了几点心得,记录一下. 1.js调用OC 我是利用wkwebview进行的开发实现,主要代码有三部分 1.向config注入OC对象 [config. ...

  7. yum 系列(一) yum 和 rpm 常用命令

    yum 系列(一) yum 和 rpm 常用命令 一.yum 常用命令 yum 命令:http://man.linuxde.net/yum yum 是在 Fedora 和 RedHat 以及 SUSE ...

  8. Lamda表达式,map和集合操作

    1.Lamda表达式,map快速获取对象的某一个属性生成集合 List<String> elementSlugs = elementInstanceBOList.stream().map( ...

  9. K8S中RC与Deployment的区别

    原文:http://fx114.net/qa-81-152379.aspx replication controller与deployment的区别 replication controller Re ...

  10. UVa 10829 L-Gap Substrings (后缀数组+rmq)

    题意:给定上一个串,问你多少种UVU这一种形式的串,其中U不为空并且V的长度给定了. 析:枚举 U 的长度L,那么U一定是经过 0 L 2L 3L .... 其中的一个,所以求两个长度反lcp,一个向 ...