/** * Gets the current settings of SimpleKMeans. * * @return an array of strings suitable for passing to setOptions() */ public String[] getOptions() { ArrayList<String> options = new ArrayList<String>(); options.add("-I"); options.add("" + getMaxIterations()); options.add("-min"); options.add("" + getMinNumClusters()); options.add("-max"); options.add("" + getMaxNumClusters()); options.add("-restarts"); options.add("" + getRestarts()); if (isManuallySelectNumClusters()) { options.add("-manual"); } if (getInitializeUsingKMeansPlusPlusMethod()) { options.add("-P"); } if (isPrintDebug()) { options.add("-debug"); } options.add("-A"); options.add( (distanceFunction.getClass().getName() + " " + Utils.joinOptions(distanceFunction.getOptions())) .trim()); return (String[]) options.toArray(new String[options.size()]); }
/** * Ustawia w??asn?? funkcj?? obliczaj??c?? odleg??o???? mi??dzy klastrami. * * @param distanceFunction Obiekt z funkcj?? dystansu. */ public void setDistanceFunction(DistanceFunction distanceFunction) { this.instancesForDistanceFunction = distanceFunction.getInstances().toString(); this.attributeIndicesForDistanceFunction = distanceFunction.getAttributeIndices(); this.invertSelectionForDistanceFunction = distanceFunction.getInvertSelection(); this.optionsForDistanseFunction = distanceFunction.getOptions().clone(); // this.distanceFunction = distanceFunction; }
/** * Pobiera funkcje odleglosci, ktora jest aktualnie w uzyciu. * * @return Obiekt zawierajacy m.in. funkcje dystansu, wszystkie instancje, a takze pozwalajacy na * obliczenie odleglosci miedzy poszczegolnymi instancjami. */ public DistanceFunction getDistanceFunction() { DistanceFunction d = new EuclideanDistance(); d.setAttributeIndices(attributeIndicesForDistanceFunction); BufferedReader reader = new BufferedReader(new StringReader(instancesForDistanceFunction)); ArffReader arff = null; try { arff = new ArffReader(reader); } catch (IOException e) { e.printStackTrace(); } d.setInstances(arff.getData()); d.setInvertSelection(invertSelectionForDistanceFunction); return d; }