正在加载图片...
数据挖掘论文 (4)计算用 Random交换代表对象O的总代价S 7//<summary> //代价函数 ///< param name=" random">可能成为新中心点这个数据的位置</ param> //< param name="j">原有中心点在数据中的位置</ param> //< param name=" ListStaff">所有数据(用链表形式进行保存)</ param> /// <returns></returns> public double Gets (int random, int j, List<Staff> ListStaff) /获取j中心点属于第几簇 int cluster= ListStaffLj] Cluster Value /获取原中心点数据数据项年龄 gAge ListStaff[j] Age value //获取原中心点数据数据项身高 double orgHeight ListStaff [j].Height Value /获取原中心点数据数据项体重 double orgWeight ListStaff[j]. Weight Value /获取可能成为新中心点数据数据项年龄 int randomAge ListStaff [random] Age Value /获取可能成为新中心点数据数据项身高 double randomHeight ListStaff[random]. Height. Value //获取可能成为新中心点数据数据项体重 double randomWeight ListStaff[random]. Weight value double orgCount =0.0 double random Count =0.0 ub=0.0; //获取这一簇里面存在的所有数据 var clusterStaff from p in Liststaff where p Cluster. Equals(cluster //遍历这一簇所有数据 foreach (var cluserRow in clusterStaff) //计算距离 double orgTempAge Math Pow(orgAge - cluserRow Age Value, 2) double orgTempHeight Math Pow(orgHeight cluserRow. Height value, 2) double orgTemp Weight Math Pow(orgWeight luserRow. Weight. Value, 2) double orgDistance = Math. Sgrt(org TempAge org TempHeight ght)数据挖掘论文 5 } (4) 计算用 Orandom 交换代表对象 Oj 的总代价 S; /// <summary> /// 代价函数 /// </summary> /// <param name="random">可能成为新中心点这个数据的位置</param> /// <param name="j">原有中心点在数据中的位置</param> /// <param name="ListStaff">所有数据(用链表形式进行保存)</param> /// <returns></returns> public double GetS(int random, int j, List<Staff> ListStaff) { //获取j中心点属于第几簇 int cluster = ListStaff[j].Cluster.Value; //获取原中心点数据数据项年龄 int orgAge = ListStaff[j].Age.Value; //获取原中心点数据数据项身高 double orgHeight = ListStaff[j].Height.Value; //获取原中心点数据数据项体重 double orgWeight = ListStaff[j].Weight.Value; //获取可能成为新中心点数据数据项年龄 int randomAge = ListStaff[random].Age.Value; //获取可能成为新中心点数据数据项身高 double randomHeight = ListStaff[random].Height.Value; //获取可能成为新中心点数据数据项体重 double randomWeight = ListStaff[random].Weight.Value; double orgCount = 0.0; double randomCount = 0.0; double sub = 0.0; //获取这一簇里面存在的所有数据 var clusterStaff = from p in ListStaff where p.Cluster.Equals(cluster) select p; //遍历这一簇所有数据 foreach (var cluserRow in clusterStaff) { //计算距离 double orgTempAge = Math.Pow(orgAge - cluserRow.Age.Value, 2); double orgTempHeight = Math.Pow(orgHeight - cluserRow.Height.Value, 2); double orgTempWeight = Math.Pow(orgWeight - cluserRow.Weight.Value, 2); double orgDistance = Math.Sqrt(orgTempAge + orgTempHeight + orgTempWeight);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有