首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

急求k-means算法范例以及讲解,

2012-08-03 
急求k-means算法实例以及讲解,急。。。。。。。。求k-means算法的例子,讲解,急。。。。。[解决办法]伪代码:

急求k-means算法实例以及讲解,急。。。。。。。。
求k-means算法的例子,讲解,急。。。。。

[解决办法]
伪代码:
=================================================================

C/C++ code
function k-means(pointSet, centerCount): List of List of Point  //返回的第1层List代表不同的分类,其中的每一个元素为该分类的点列。//用随机数初始化中心点centerPoints= new array of point[centerCount];result= new List;for (i= 0; i< centerCount; i++) {    centerPoints[i]= createRandomPoint();    result.Add(new List());}needCalc = true;  //设置循环标志While needCalc {    //清除原有分类    for (i= 0; i<centerCount; i++){      result.get(i).clear();    }    //每一个点进行分类    for (i= 0; i< pointSet.length; i++) {      centerPointIndex= -1;      minDistance:= 0;      for (j=0; j<centerCount; j++) {          //函数getDistance用来计算两点之间的距离          currentDistance=getDistance(pointSet.get(i), centerPoints[i]);          if (centerPointIndex<0) || (minDistance>currentDistance)  {              centerPointIndex:= j;              minDistance:=currentDistance;          }          result.get(centerPointIndex).add(pointSet.get(i));      }    }    //计算新分类的中心点    for (i=0; i<centerCount; i++) {       centerPoints.set(i, getCenter(result.get(CenterPointIndex)));    }    if (XXX) 判断是否满足结束条件        needCalc = true    else       needCalc = false;} 

热点排行