public List<String[]> findPoints(Cluster data, List<AttributeCluster> attrbs) { List<String[]> list = new ArrayList<String[]>(); for (int i = 0; i < data.size(); i++) { list.add(getPoints(attrbs, data.getRecords().get(i))); } return list; }
/** * Add points from cluster to Bisect Cluster data model * * @param bisect * @param data */ public void addClusterPoints(BisectCluster bisect, Cluster data) { CluseterList list = new CluseterList(); list.addCluster(bisect.getC1()); list.addCluster(bisect.getC2()); list.clearsClusterPoints(); for (int i = 0; i < data.size(); i++) { int temp = findClosestClusterAndAddPoint( list, getPoints(data.getAttributes(), data.getRecords().get(i))); list.getClusterAt(temp).addPoints(data.getRecords().get(i)); } calculateSSEForCluster(bisect.getC1()); // System.out.println(bisect.getC1().getSSE()); calculateSSEForCluster(bisect.getC2()); bisect.setTotalSSE(bisect.getC1().getSSE() + bisect.getC2().getSSE()); }
/** * Calculates SSE * * @param cluster */ public void calculateSSEForCluster(Cluster cluster) { double SSE = 0.0; for (int i = 0; i < cluster.size(); i++) { double temp = findEucleideanDistance( cluster.getCentroid().getAttrList(), getPoints(cluster.getAttributes(), cluster.getRecords().get(i))); SSE += temp * temp; } cluster.setSSE(SSE); }