正在加载图片...
数据挖掘论文 Staff. Add (aStaff) ChangedlistStaff OrgionListstaff return Staff (3)将每个剩余的对象指派到最近的中心点所代表的簇 77/ <summary> ///指派每个剩余的对象给离它最近的中心点所代表的簇 ///< //< param name="k">分成k簇</ param> /// param name="ChangedListStaff" >*E</param> //< param name=" CentainPoint">中心点集合</ param /// <returns>/returns> public List<Staff> SetClusterList(int k, List<Staff> ChangedListStaff List<Staff> CentainPoint //得到数据的个数 int count ChangedListstaff. Count: //指派每个剩余的对象给离它最近的中心点所代表的簇 for (int i=0: i< count; i++) List<double> temp PointDistance new List<double>o //如果不是中心点(Fag代表是否为中心点,1为中心点 if (! ChangedListStaff[]. Flag. Equals (1)) //计算剩余的点到每个中心点的距离,然后分到距离最小的那一簇里面 for (int j=0:j<k: j++) double tempAge Math Pow(ChangedListStaff[i] Age value CentainPoint [j] Age Value, 2) double tempHeight =Math. Pow(ChangedListStaff[]. HeightValue CentainPoint [jl. Height value, 2) double tempWeight= Math. Pow(ChangedListStaff[i]. Weight. value CentainPoint [j]. Weight Value, 2) double temp Math Sgrt(tempAgetempHeight+tempWeight) tempPointDistance. Add (temp) double min tempPointDistance Min o int index tempPointDistance. IndexOf (min) ChangedListStaff[i]. Cluster index return Changedliststaff数据挖掘论文 4 _Staff.Add(aStaff); } ChangedListStaff = OrgionListStaff; return _Staff; } (3) 将每个剩余的对象指派到最近的中心点所代表的簇 /// <summary> /// 指派每个剩余的对象给离它最近的中心点所代表的簇 /// </summary> /// <param name="k">分成k簇</param> /// <param name="ChangedListStaff">数据</param> /// <param name="CentainPoint">中心点集合</param> /// <returns></returns> public List<Staff> SetClusterList(int k, List<Staff> ChangedListStaff, List<Staff> CentainPoint) { //得到数据的个数 int count = ChangedListStaff.Count; //指派每个剩余的对象给离它最近的中心点所代表的簇 for (int i = 0; i < count; i++) { List<double> tempPointDistance = new List<double>(); //如果不是中心点(Flag代表是否为中心点,1为中心点) if (!ChangedListStaff[i].Flag.Equals(1)) { //计算剩余的点到每个中心点的距离,然后分到距离最小的那一簇里面 for (int j = 0; j < k; j++) { double tempAge = Math.Pow(ChangedListStaff[i].Age.Value - CentainPoint[j].Age.Value, 2); double tempHeight =Math.Pow(ChangedListStaff[i].Height.Value - CentainPoint[j].Height.Value, 2); double tempWeight = Math.Pow(ChangedListStaff[i].Weight.Value - CentainPoint[j].Weight.Value, 2); double temp = Math.Sqrt(tempAge+tempHeight+tempWeight); tempPointDistance.Add(temp); } double min = tempPointDistance.Min(); int index = tempPointDistance.IndexOf(min); ChangedListStaff[i].Cluster = index; } } return ChangedListStaff;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有