赞
踩
1 <?php2 /*
3 *Kmodes算法(聚类算法的实现)4 */
5
6
7 /*
8 *获取簇的数目9 */
10 //--------------------------------------------------------------------
11 function Category($train)12 {13 $category = array(NULL);//存放不同的类别
14 array_splice($category,0,1);15
16 for($i=1;$i
19 for($j=0;$j
35
36 /*
37 *获得初始矩阵M38 */
39 //--------------------------------------------------------------------
40 function first_M($train)41 {42 $category = Category($train);43 $M = array(NULL);44 array_splice($M,0,1);45 $num = 1;46 for($j=0;$j
54 array_splice($temp,0,1);55 array_splice($temp,count($temp)-1,1);56 array_push($M,$temp);57 $num++;58 break;59 }else{60 $num++;61 }62 }63 }64 /*echo "
";65 print_r($M);66 */
67 return $M;68 }69 //---------------------------------------------
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。