In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use the Java of K-means algorithm to realize clustering analysis of 681 warriors of the three Kingdoms, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
First, introduction of k-means algorithm:
K-means algorithm accepts the input k, and then divides n data objects into k clusters to make the clustering satisfied: the similarity of objects in the same cluster is higher, while the similarity of objects in different clusters is smaller. Clustering similarity is calculated by using a "center object" (gravity center) obtained by the average value of objects in each cluster. K clusters have the following characteristics: each cluster itself is as compact as possible, while each cluster is separated as far as possible. K clusters have the following characteristics: each cluster itself is as compact as possible, while each cluster is separated as far as possible.
The working process of the k-means algorithm is as follows: first, k objects are randomly selected from n data objects as the initial clustering center; for the remaining objects, they are assigned to the most similar cluster (represented by the cluster center) according to their similarity (distance) to these cluster centers, and then the cluster center of each new cluster (the mean value of all objects in the cluster) is calculated. This process is repeated until the standard measure function begins to converge. The mean square deviation is generally used as the standard measure function. K clusters have the following characteristics: each cluster itself is as compact as possible, while each cluster is separated as far as possible.
Second, the basic steps of k-means algorithm:
(1) randomly select k objects from n data objects as the initial clustering center
(2) calculate the distance between each object and these central objects according to the mean value of each clustering object (central object), and redivide the corresponding objects according to the minimum distance.
(3) recalculate the mean of each (changing) cluster (central object)
(4) calculate the standard measure function, and when certain conditions are satisfied, such as the convergence of the function, the algorithm terminates; if the condition is not satisfied, then go back to step (2) and repeat until the standard measure function begins to converge. (the mean square deviation is generally used as the standard measure function. )
Third, the java implementation of k-means algorithm:
There are a total of seven classes, General.java represents the general object, Distance.java distance class calculates the distance between each general and all generals in the cluster, Kmeans.java core clustering algorithm class, Tool.java tool class used to convert generals star to digital and other operations, TestKmeans.java test class is the entry file, DomParser.java is used to read xml in the 681 generals.
Specific ideas: first read from the general.xml file 681 generals, and then randomly select the initial class center, calculate the distance from each general to the center, clustering according to the minimum distance, and then recalculate the distance from each general to the new central general according to the average value of the new clustering class center, until the updated clustering and the original cluster contains the general will no longer change, that is, the end of convergence.
The specific code is as follows:
1,General.java
Package kmeans; public class General {private String name; / / name private int render; / / Star private int tongshai; / / Commander private int wuli; / / Force private int zhili; / / intellectual private int polic; / / political private int qiangbin; / / Rifleman private int jibin; / / Hubing private int nubin / / crossbow private int qibin; / / Cavalry private int binqi; / / weapon private int tongwu; / / Tong Wu private int tongzhi; / / Tong Zhi private int tongwuzhi; / / Tong Wu Zhi private int tongwuzhizheng; / / Tong Wu Zhi Zheng private int salary / 50 salary public General (int render, String name, int tongshai, int wuli, int zhili, int polic, int qiangbin, int jibin, int nubin, int qibin, int binqi, int tongwu, int tongzhi, int tongwuzhi, int tongwuzhizheng, int salary) {super (); this.name = name; this.render = render; this.tongshai = tongshai This.wuli = wuli; this.zhili = zhili; this.polic = polic; this.qiangbin = qiangbin; this.jibin = jibin; this.nubin = nubin; this.qibin = qibin; this.binqi = binqi; this.tongwu = tongwu; this.tongzhi = tongzhi; this.tongwuzhi = tongwuzhi; this.tongwuzhizheng = tongwuzhizheng This.salary = salary;} public General (int render, int tongshai, int wuli, int zhili, int polic, int qiangbin, int jibin, int nubin, int qibin, int binqi, int tongwu, int tongzhi, int tongwuzhi, int tongwuzhizheng, int salary) {super (); this.name = "Cluster Center"; this.render = render This.tongshai = tongshai; this.wuli = wuli; this.zhili = zhili; this.polic = polic; this.qiangbin = qiangbin; this.jibin = jibin; this.nubin = nubin; this.qibin = qibin; this.binqi = binqi; this.tongwu = tongwu; this.tongzhi = tongzhi; this.tongwuzhi = tongwuzhi This.tongwuzhizheng = tongwuzhizheng; this.salary = salary } public General () {} @ Override public String toString () {return "generals [name=" + name + ", render=" + Tool.dxingji (render) + ", tongshai=" + tongshai + ", wuli=" + wuli + ", zhili=" + zhili + ", polic=" + polic + ", qiangbin=" + Tool.dchange (qiangbin) + " Jibin= "+ Tool.dchange (jibin) +", nubin= "+ Tool.dchange (nubin) +", qibin= "+ Tool.dchange (qibin) +", binqi= "+ Tool.dchange (binqi) +", tongwu= "+ tongwu +", tongzhi= "+ tongzhi +", tongwuzhi= "+ tongwuzhi +", tongwuzhizheng= "+ tongwuzhizheng +", salary= "+ salary +"] " } public String getName () {return name;} public void setName (String name) {this.name = name;} public int getRender () {return render;} public void setRender (int render) {this.render = render;} public int getTongshai () {return tongshai } public void setTongshai (int tongshai) {this.tongshai = tongshai;} public int getWuli () {return wuli;} public void setWuli (int wuli) {this.wuli = wuli;} public int getZhili () {return zhili;} public void setZhili (int zhili) {this.zhili = zhili } public int getPolic () {return polic;} public void setPolic (int polic) {this.polic = polic;} public int getQiangbin () {return qiangbin;} public void setQiangbin (int qiangbin) {this.qiangbin = qiangbin;} public int getJibin () {return jibin } public void setJibin (int jibin) {this.jibin = jibin;} public int getNubin () {return nubin;} public void setNubin (int nubin) {this.nubin = nubin;} public int getQibin () {return qibin;} public void setQibin (int qibin) {this.qibin = qibin } public int getBinqi () {return binqi;} public void setBinqi (int binqi) {this.binqi = binqi;} public int getTongwu () {return tongwu;} public void setTongwu (int tongwu) {this.tongwu = tongwu;} public int getTongzhi () {return tongzhi } public void setTongzhi (int tongzhi) {this.tongzhi = tongzhi;} public int getTongwuzhi () {return tongwuzhi;} public void setTongwuzhi (int tongwuzhi) {this.tongwuzhi = tongwuzhi;} public int getTongwuzhizheng () {return tongwuzhizheng;} public void setTongwuzhizheng (int tongwuzhizheng) {this.tongwuzhizheng = tongwuzhizheng } public int getSalary () {return salary;} public void setSalary (int salary) {this.salary = salary;}}
2,Distance.java
Package kmeans; / * this class is used to calculate distances. * * / public class Distance {int dest;// destination int source;// source double dist;// Euclidean distance public int getDest () {return dest;} public void setDest (int dest) {this.dest = dest;} public int getSource () {return source } public void setSource (int source) {this.source = source;} public double getDist () {return dist;} public void setDist (double dist) {this.dist = dist } / * calculate the distance between source and destination * @ param dest destination general * @ param source source general * @ param dist distance * / public Distance (int dest, int source, double dist) {this.dest = dest; this.source = source; this.dist = dist } public Distance () {}}
3,Cluster.java
Package kmeans; import java.util.ArrayList; public class Cluster {the id private ArrayList ofCluster of the central generals of private int center;// clustering = new ArrayList (); / / the collection of generals belonging to this cluster public int getCenter () {return center;} public void setCenter (int center) {this.center = center;} public ArrayList getOfCluster () {return ofCluster } public void setOfCluster (ArrayList ofCluster) {this.ofCluster = ofCluster;} public void addGeneral (General general) {if (! (this.ofCluster.contains (general) this.ofCluster.add (general);}}
4,Kmeans.java
Package kmeans; import java.util.*; public class Kmeans {public ArrayList allGenerals = null; public int totalNumber = 0 prepare () / get the number of all generals public int K = 0 allGenerals.size / suppose Kang 10 public Kmeans () {allGenerals = new DomParser (). Prepare (); totalNumber = allGenerals.size (); K = 3 } / / the first random selection of the cluster center public Set firstRandom () {Set center = new HashSet (); / / the id of the points of the cluster center, using set to ensure that there will be no repetition of id Random ran = new Random (); int roll = ran.nextInt (totalNumber); while (center.size ())
< K) { roll = ran.nextInt(totalNumber); center.add(roll); } return center; } // 根据聚类中心初始化聚类信息 public ArrayList init(Set center) { ArrayList cluster = new ArrayList();// 聚类 的数组 Iterator it = center.iterator(); while (it.hasNext()) { Cluster c = new Cluster();// 代表一个聚类 c.setCenter(it.next()); cluster.add(c); } return cluster; } /** * 计算各个武将到各个聚类中心的距离,重新聚类 * * @param cluster * 聚类数组,用来聚类的,根据最近原则把武将聚类 * @param center * 中心点id,用于计算各个武将到中心点的距离 return cluster 聚类后的所有聚类组成的数组 */ public ArrayList juLei(Set center, ArrayList cluster) { ArrayList distence = new ArrayList();// 存放距离信息,表示每个点到各个中心点的距离组成的数组 General source = null; General dest = null; int id = 0;// 目的节点id int id2 = 0;// 源节点id Object[] p = center.toArray();// p 为聚类中心点id数组 boolean flag = false; // 分别计算各个点到各个中心点的距离,并将距离最小的加入到各个聚类中,进行聚类 for (int i = 0; i < totalNumber; i++) { // 每个点计算完,并聚类到距离最小的聚类中就清空距离数组 distence.clear(); // 计算到j个类中心点的距离,便利各个中心点 for (int j = 0; j < center.size(); j++) { // 如果该点不在中心点内 则计算距离 if (!(center.contains(i))) { flag = true; // 计算距离 source = allGenerals.get(i);// 某个点 dest = allGenerals.get((Integer) p[j]);// 各个 中心点 // 计算距离并存入数组 distence.add(new Distance((Integer) p[j], i, Tool.juli( source, dest))); } else { flag = false; } } // 说明计算完某个武将到类中心的距离,开始比较 if (flag == true) { // 排序比较一个点到各个中心的距离的大小,找到距离最小的武将的 目的id,和源id, // 目的id即类中心点id,这个就归到这个中心点所在聚类中 double min = distence.get(0).getDist();// 默认第一个distance距离是最小的 // 从1开始遍历distance数组 int minid = 0; for (int k = 1; k < distence.size(); k++) { if (min >Distence.get (k). GetDist () {min = distence.get (k). GetDist (); id = distence.get (k). GetDest (); / / purpose, that is, id2 = distence.get (k). GetSource (); / / some general minid = k } else {id = distence.get (minid) .getDest (); id2 = distence.get (minid) .getSource () }} / / traverse the cluster clustering array to find the same clustering for (int n = 0; n) where the center point of the class id is the same as the minimum distance destination id.
< cluster.size(); n++) { // 如果和中心点的id相同 则setError if (cluster.get(n).getCenter() == id) { cluster.get(n).addGeneral(allGenerals.get(id2));// 将与该聚类中心距离最小的武将加入该聚类 break; } } } } return cluster; } // 产生新的聚类中心点数组 public Set updateCenter() { Set center = new HashSet(); for (int i = 0; i < K; i++) { center.add(i); } return center; } // 更新聚类中心, 求平均值 public ArrayList updateCluster(ArrayList cluster) { ArrayList result = new ArrayList(); // 重新产生的新的聚类中心组成的数组 // k个聚类进行更新聚类中心 for (int j = 0; j < K; j++) { ArrayList ps = cluster.get(j).getOfCluster();// 该聚类的所有 武将 // 组成的数组 ps.add(allGenerals.get(cluster.get(j).getCenter()));// 同时将该类中心对应的武将加入该武将数组 int size = ps.size();// 该聚类的长度大小 // 计算和,然后在计算平均值 int sumrender = 0, sumtongshai = 0, sumwuli = 0, sumzhili = 0, sumjibin = 0, sumnubin = 0, sumqibin = 0, sumpolic = 0, sumqiangbin = 0, sumbinqi = 0, sumtongwu = 0, sumtongzhi = 0, sumtongwuzhi = 0, sumtongwuzhizheng = 0, sumsalary = 0; for (int k1 = 0; k1 < size; k1++) { sumrender += ps.get(k1).getRender(); sumtongshai += ps.get(k1).getRender(); sumwuli += ps.get(k1).getWuli(); sumzhili += ps.get(k1).getZhili(); sumjibin += ps.get(k1).getJibin(); sumnubin += ps.get(k1).getNubin(); sumqibin += ps.get(k1).getQibin(); sumpolic += ps.get(k1).getPolic(); sumqiangbin += ps.get(k1).getQiangbin(); sumbinqi += ps.get(k1).getBinqi(); sumtongwu += ps.get(k1).getTongwu(); sumtongzhi += ps.get(k1).getTongzhi(); sumtongwuzhi += ps.get(k1).getTongwuzhi(); sumtongwuzhizheng += ps.get(k1).getTongwuzhizheng(); sumsalary += ps.get(k1).getSalary(); } // 产生新的聚类,然后加入到聚类数组中 Cluster newCluster = new Cluster(); newCluster.setCenter(j); // 计算平均值并构造新的武将对象 newCluster.addGeneral(new General(sumrender / size, sumtongshai / size, sumwuli / size, sumzhili / size, sumjibin / size, sumnubin / size, sumqibin / size, sumpolic = 0, sumqiangbin = 0, sumbinqi / size, sumtongwu / size, sumtongzhi / size, sumtongwuzhi / size, sumtongwuzhizheng / size, sumsalary / size)); result.add(newCluster); } return result; } /** * 计算各个武将到各个更新后的聚类中心的距离,重新聚类 * @param update 更新后的聚类中心 * @param cluster 要存储的聚类中心 */ public ArrayList updateJuLei(ArrayList update, ArrayList cluster) { ArrayList distence = new ArrayList();// 存放距离信息,表示每个点到各个中心点的距离组成的数组 General source = null; General dest = null; int id = 0;// 目的节点id int id2 = 0;// 源节点id //Object[] p = center.toArray();// p 为聚类中心点id数组 boolean flag = false; // 分别计算各个点到各个中心点的距离,并将距离最小的加入到各个聚类中,进行聚类 for (int i = 0; i < totalNumber; i++) { // 每个点计算完,并聚类到距离最小的聚类中就清空距离数组 distence.clear(); // 计算到j个类中心点的距离,便利各个中心点 //for (int j = 0; j < center.size(); j++) { for (int j = 0; j < update.size(); j++) { // 如果该点不在中心点内 则计算距离 //if (!(center.contains(i))) { flag = true; // 计算距离 source = allGenerals.get(i);// 某个点 // dest = allGenerals.get((Integer) p[j]);// 各个 中心点 dest = update.get(j).getOfCluster().get(0);// 各个 中心点 // 计算距离并存入数组 //distence.add(new Distance((Integer) p[j], i, Tool.juli( distence.add(new Distance(update.get(j).getCenter(), i, Tool.juli( source, dest))); /*} else { flag = false; }*/ } // 说明计算完某个武将到类中心的距离,开始比较 if (flag == true) { // 排序比较一个点到各个中心的距离的大小,找到距离最小的武将的 目的id,和源id, // 目的id即类中心点id,这个就归到这个中心点所在聚类中 double min = distence.get(0).getDist();// 默认第一个distance距离是最小的 // 从1开始遍历distance数组 int mid = 0; for (int k = 1; k < distence.size(); k++) { if (min >Distence.get (k). GetDist () {min = distence.get (k). GetDist (); id = distence.get (k). GetDest (); / / purpose, that is, id2 = distence.get (k). GetSource (); / / some general mid = k } else {id = distence.get (mid) .getDest (); id2 = distence.get (mid) .getSource () }} / / traverses the cluster clustering array to find the same clustering for (int n = 0; n < cluster.size ()) where the center point of the class id is the same as the minimum distance destination id SetError if (cluster.get (n). GetCenter () = = id) {cluster.get (n) .addGeneral (allGenerals.get (id2)) / / the Wu who will have the smallest distance from the cluster center will join the cluster} return cluster;} / / continuous cyclic clustering until each cluster does not redistribute public ArrayList getResult () {ArrayList result = new ArrayList (); ArrayList temp = new ArrayList () Boolean flag = false; / / get the random center and then cluster Set center = firstRandom (); result = juLei (center, init (center)); print (result); do {/ / re-cluster ArrayList up = updateCluster (result); / / the new cluster center ArrayList cluster = init (updateCenter ()) / / get the clustering array temp = updateJuLei (up, cluster); / / print (temp); flag = isEquals (temp, result); result = temp;} while (! flag); return result;} public boolean isEquals (ArrayList temp, ArrayList result) {boolean flag = false If (temp.size ()! = result.size ()) {return flag;} for (Cluster tem: temp) {for (Cluster res: result) {if (tem.getCenter () = = res.getCenter ()) {flag = true }} / / if a round is not found, then two clusters if (flag = = false) {return false;} else {/ / if a round is found, then look for flag = false }} / / if the code can go this way, it means true flag = true; return flag } / / output all clustering public void print (ArrayList cs) {System.out.println ("* *"); for (int I = 0; I < cs.size (); iCluster +) {Cluster c = cs.get (I) System.out.println ("- -"); System.out.println ("center:" + allGenerals.get (c.getCenter (); ArrayList p = c.getOfCluster (); for (int j = 0) J < p.size (); jacks +) {System.out.println ("general:" + p.get (j) + "\ n");}}
5,Tool.java
Package kmeans; public class Tool {/ / convert the proficiency of various weapons to digital public static int change (String str) {int result = str.equals ("fine")? 4: (str.equals ("god")? 3: (str.equals ("communication")? 2: 1); return result } / / convert stars to digits public static int xingji (String str) {int result = str.equals ("★")? 5: (str.equals ("★★★★")? 4: (str.equals ("★★★")? 3: (str.equals ("★★")? 2: 1)); return result } / / reverse the number of weapons into proficiency public static String dchange (int str) {String result = str== 4? "Jing": (str== 3? God: (str== 2? Return result;} / / inverts the number to star public static String dxingji (int str) {String result = str== 5? "★": (str== 4? "★★★★": (str== 3? "★★★": (str== 2? "★★": "★")); return result } / / two general objects are passed in to calculate the Euclidean distance. Public static double juli (General G1, General G2) {double result = (Double) Math.sqrt (StrictMath.pow (g1.getRender ()-g2.getRender (), 2) + StrictMath.pow (g1.getTongshai ()-g2.getTongshai (), 2) + StrictMath.pow (g1.getWuli ()-g2.getWuli (), 2) + StrictMath.pow (g1.getZhili ()-g2.getZhili ()) 2) + StrictMath.pow (g1.getPolic ()-g2.getPolic (), 2) + StrictMath.pow (g1.getQiangbin ()-g2.getQiangbin (), 2) + StrictMath.pow (g1.getQibin ()-g2.getQibin (), 2) + StrictMath.pow (g1.getJibin ()-g2.getJibin () 2) + StrictMath.pow (g1.getNubin ()-g2.getNubin (), 2) + StrictMath.pow (g1.getBinqi ()-g2.getBinqi (), 2) + StrictMath.pow (g1.getTongwu ()-g2.getTongwu (), 2) + StrictMath.pow (g1.getTongzhi ()-g2.getTongzhi () 2) + StrictMath.pow (g1.getTongwuzhizheng ()-g2.getTongwuzhizheng (), 2) + StrictMath.pow (g1.getTongwuzhi ()-g2.getTongwuzhi (), 2) + StrictMath.pow (g1.getSalary ()-g2.getSalary (), 2)) Return result;}}
6,DomParser.java
Package kmeans; import javax.xml.parsers.*; import java.io.*; import java.util.ArrayList; import org.w3c.dom.*; import org.xml.sax.SAXException; public class DomParser {private ArrayList generals = new ArrayList (); public ArrayList prepare () {/ / get dom parser factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance (); factory.setIgnoringElementContentWhitespace (true) / / get dom parser DocumentBuilder builder = null; try {builder = factory.newDocumentBuilder ();} catch (ParserConfigurationException e) {e.printStackTrace ();} / / parse the document Document doc = null; try {doc = builder.parse (new File ("general.xml")) } catch (SAXException e) {e.printStackTrace ();} catch (IOException e) {e.printStackTrace ();} / / get the root node Element generalList = doc.getDocumentElement (); / / get all row nodes NodeList nodeList = generalList.getElementsByTagName ("Row") / / facilitates all row nodes for (int I = 1; I < nodeList.getLength (); iTunes +) {System.out.println ("- the" + I + "element-"); Node row = nodeList.item (I) / / get all Data data NodeList attList = row.getChildNodes () / / get each part of the data and add generals.add (new General (Tool.xingji (attList.item (1). GetTextContent ()), attList.item (3). GetTextContent (), Integer.parseInt (attList.item (5). GetTextContent ()) to ArrayList Integer.parseInt (attList.item (7). GetTextContent ()), Integer.parseInt (attList.item (9). GetTextContent ()), Integer.parseInt (attList.item (11). GetTextContent ()), Tool.change (attList.item (13). GetTextContent ()) Tool.change (attList.item (15). GetTextContent ()), Tool.change (attList.item (17). GetTextContent ()), Tool.change (attList.item (19). GetTextContent ()), Tool.change (attList.item (21). GetTextContent ()) Integer.parseInt (attList.item (23). GetTextContent ()), Integer.parseInt (attList.item (25). GetTextContent ()), Integer.parseInt (attList.item (27). GetTextContent ()), Integer.parseInt (attList.item (29). GetTextContent ()) Integer.parseInt (attList.item (31) .getTextContent () System.out.println ("Star:" + Tool.xingji (attList.item (1). GetTextContent ()) + "name:" + attList.item (3). GetTextContent () + "Command:" + attList.item (5). GetTextContent () + "Force:" + attList.item (7). GetTextContent () + "Intelligence:" + attList.item (9). GetTextContent () + "Politics:" + attList.item (11). GetTextContent () + "Rifleman:" + Tool.change (attList.item (13). GetTextContent ()) + "Haobing:" + Tool.change (attList.item (15). GetTextContent ()) + "crossbow:" + Tool.change (attList.item (17). GetTextContent ()) + "Cavalry:" + Tool.change (attList.item (19). GetTextContent ()) + "weapon:" + Tool.change (attList.item (21). GetTextContent ()) + "system" Wu: "+ attList.item (23). GetTextContent () +" Tong Zhi: "+ attList.item (25). GetTextContent () +" Tong Wu Zhi: "+ attList.item (27). GetTextContent () +" Tong Wu Zhizheng: "+ attList.item (29). GetTextContent () +" 50 salary: " + attList.item (31) .getTextContent () + "") / * * for (int j = 0; j < attList.getLength (); jacks +) {* System.out.println (attList.item (j). GetTextContent ());} * /} return generals;}}
7,TestKmeans.java
Package kmeans; public class TestKmeans {public static void main (String [] args) {Kmeans_eold kmeans = new Kmeans_eold (); kmeans.print (kmeans.getResult ());}}
Attached part of general.xml:
2006-09-13T11:21:51Z 2012-04-26T13:39:57Z 14.00 5850 11070 090 False False Star name commands Force intellectual Politics Gunmen, crossbowmen, crossbowmen, cavalry, weapons, Wu Zhizheng, 50 grade salary ★ Lv Bu 87 100 26 13 Jingshen 161 194 257 350 19250 ★ Zhang Fei 85 98 30 22 Shen Shu 168 193 264 350 19250 ★ Yu 95 97 75 62 Shen Tong Shu 165 191 260 347 19085 ★ Ma Chao 88 97 44 26 proficient Shentong 168 187 259 353 19415 ★ Zhao Kun 91 96 76 65 Shen Tong Shen 192 170 267 329 18095 ★ Xu Yun 65 96 36 20 Jingtong Shutong 161 101 197 217 11935 ★ Dian Wei 56 95 35 29 Jingshu 151 91 186215 11825 ★ Ganning 86 94 76 18 God 181 183 270 351 19305 ★ pound 80 94 70 44 174150 244 288 15840 ★ manuscripts 78 94 25 25 mastering Jingshu 172 103 197 222 12210 ★ Huang Zhong 86 93 60 52 Shu 185 171 263 321 17655 ★ Tai Shi ci 82 93 66 58 Jingshen Shu 175 148 241 299 16445 ★ Yan Liang 79 93 42 32 Jingshu Shenshu 172 121 214 246 13530 ★ Zhang Liao 93 92 78 58 Shen Tong 183 167 257 330 18150 ★ Sun ze 92 92 69 70 Shen Jing Shenjing 130 192 230 325 17875 ★ Wei Yan 81 92 69 49 Jingshen Tongshu 173 150 242 291 16005 ★ Hua Xiong 81 92 56 40 Tong Tong Shu Shen Shu 173 137 229 269 14795
The screenshot of the final running result is as follows:
Read the general's data as shown in the picture.
Some screenshots after running:
After reading the above, do you know how to use the Java of K-means algorithm to cluster and analyze 681 warriors of the three Kingdoms? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.