用C#实现k均值聚类算法
k均值算法是模式识别的聚分类问题,这是用C#实现其算法
以下是程序源代码:
using System;
using ;
using ;
using ponentModel;
using ;
using ;
namespace KMean_win
{
///
/// Form1 的摘要说明。
///
public class Form1 :
{
///
/// 必需的设计器变量。
///
private = null;
private static int k = 2; //类数,此例题为2类
private static int total = 20; //点个数
private int test = 0;
private PointF[] unknown = new PointF[total]; //点数组
private int[] type = new int[total]; //每个点暂时的类
public PointF[] z = new PointF[k]; //保存新的聚类中心
public PointF[] z0 = new PointF[k]; //保存上一次的聚类中心
private PointF sum;
private int temp = 0;
private textBox1;
private int l = 0; //迭代次数
//构造函数,初始化
public Form1()
{
unknown[0]=new Point(0,0);
unknown[1]=new Point(1,0);
unknown[2]=new Point(0,1);
unknown[3]=new Point(1,1);
unknown[4]=new Point(2,1);
unknown[5]=new Point(1,2);
unknown[6]=ne
用c#实现k均值聚类算法 来自淘豆网m.daumloan.com转载请标明出处.