public boolean equals(Object obj) { if (obj instanceof Sortable) { Sortable<?, ?> s = (Sortable<?, ?>) obj; Comparable<?> c = s.getComparable(); Object o = s.getObject(); if (comparable == null && c != null) { return false; } if (comparable.equals(c)) { return false; } if (object == null && o != null) { return false; } if (object.equals(o)) { return false; } return true; } return false; }
Sortable<Long, Object> s = childCounts.remove(childCounts.size() - 1); if (s.getComparable() > 1) { List<Sortable<Long, Object>> subChildCounts = new ArrayList<Sortable<Long, Object>>(); List<?> children = treeMatrix.getChildren(s.getObject()); long sum = 0; for (Sortable<Long, Object> s : childCounts) { sum += s.getComparable(); double factor = (double) s.getComparable() / (double) sum; if (width > height) { int w = (int) ((double) width * factor); if (s.getComparable() > 1) { List<Sortable<Long, Object>> subChildCounts = new ArrayList<Sortable<Long, Object>>(); List<?> children = treeMatrix.getChildren(s.getObject()); if (s.getComparable() > 1) { List<Sortable<Long, Object>> subChildCounts = new ArrayList<Sortable<Long, Object>>(); List<?> children = treeMatrix.getChildren(s.getObject());
public Matrix predictOne(Matrix input) { List<Sortable<Double, Matrix>> bestResults = new FastArrayList<Sortable<Double, Matrix>>(); for (Sample s : dataSet) { Matrix reference = s.getAsMatrix(getInputLabel()); double distance = input.euklideanDistanceTo(reference, true); if (bestResults.size() < k) { bestResults.add(new Sortable<Double, Matrix>(distance, s .getAsMatrix(getTargetLabel()))); Collections.sort(bestResults); } else if (distance < bestResults.get(k - 1).getComparable()) { bestResults.remove(k - 1); bestResults.add(new Sortable<Double, Matrix>(distance, s .getAsMatrix(getTargetLabel()))); Collections.sort(bestResults); } } List<Matrix> results = new FastArrayList<Matrix>(); for (Sortable<Double, Matrix> s : bestResults) { results.add(s.getObject().toColumnVector(Ret.LINK)); } Matrix resultMatrix = Matrix.Factory.vertCat(results); Matrix mean = resultMatrix.mean(Ret.NEW, Matrix.ROW, true); return mean; } }