/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
/** * Run the algorithm * * @param db Database * @param relation Relation * @return Clustering hierarchy */ public PointerDensityHierarchyRepresentationResult run(Database db, Relation<O> relation) { final DistanceQuery<O> distQ = db.getDistanceQuery(relation, getDistanceFunction()); final KNNQuery<O> knnQ = db.getKNNQuery(distQ, minPts); // We need array addressing later. final ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs()); // 1. Compute the core distances // minPts + 1: ignore query point. final WritableDoubleDataStore coredists = computeCoreDists(ids, knnQ, minPts); final int numedges = ids.size() - 1; DoubleLongHeap heap = new DoubleLongMinHeap(numedges); // 2. Build spanning tree. FiniteProgress mprog = LOG.isVerbose() ? new FiniteProgress("Computing minimum spanning tree (n-1 edges)", numedges, LOG) : null; PrimsMinimumSpanningTree.processDense(ids,// new HDBSCANAdapter(ids, coredists, distQ), // new HeapMSTCollector(heap, mprog, LOG)); LOG.ensureCompleted(mprog); // Storage for pointer representation: WritableDBIDDataStore pi = DataStoreUtil.makeDBIDStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC); WritableDoubleDataStore lambda = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC, Double.POSITIVE_INFINITY); convertToPointerRepresentation(ids, heap, pi, lambda); return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, coredists); }
/** * Run the algorithm * * @param db Database * @param relation Relation * @return Clustering hierarchy */ public PointerDensityHierarchyRepresentationResult run(Database db, Relation<O> relation) { final DistanceQuery<O> distQ = db.getDistanceQuery(relation, getDistanceFunction()); final KNNQuery<O> knnQ = db.getKNNQuery(distQ, minPts); // We need array addressing later. final ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs()); // 1. Compute the core distances // minPts + 1: ignore query point. final WritableDoubleDataStore coredists = computeCoreDists(ids, knnQ, minPts); final int numedges = ids.size() - 1; DoubleLongHeap heap = new DoubleLongMinHeap(numedges); // 2. Build spanning tree. FiniteProgress mprog = LOG.isVerbose() ? new FiniteProgress("Computing minimum spanning tree (n-1 edges)", numedges, LOG) : null; PrimsMinimumSpanningTree.processDense(ids, // new HDBSCANAdapter(ids, coredists, distQ), // new HeapMSTCollector(heap, mprog, LOG)); LOG.ensureCompleted(mprog); // Storage for pointer representation: WritableDBIDDataStore pi = DataStoreUtil.makeDBIDStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC); WritableDoubleDataStore lambda = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC, Double.POSITIVE_INFINITY); convertToPointerRepresentation(ids, heap, pi, lambda); return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, distQ.getDistanceFunction().isSquared(), coredists); }
/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
/** * Run the algorithm * * @param db Database * @param relation Relation * @return Clustering hierarchy */ public PointerDensityHierarchyRepresentationResult run(Database db, Relation<O> relation) { final DistanceQuery<O> distQ = db.getDistanceQuery(relation, getDistanceFunction()); final KNNQuery<O> knnQ = db.getKNNQuery(distQ, minPts); // We need array addressing later. final ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs()); // 1. Compute the core distances // minPts + 1: ignore query point. final WritableDoubleDataStore coredists = computeCoreDists(ids, knnQ, minPts); final int numedges = ids.size() - 1; DoubleLongHeap heap = new DoubleLongMinHeap(numedges); // 2. Build spanning tree. FiniteProgress mprog = LOG.isVerbose() ? new FiniteProgress("Computing minimum spanning tree (n-1 edges)", numedges, LOG) : null; PrimsMinimumSpanningTree.processDense(ids, // new HDBSCANAdapter(ids, coredists, distQ), // new HeapMSTCollector(heap, mprog, LOG)); LOG.ensureCompleted(mprog); // Storage for pointer representation: WritableDBIDDataStore pi = DataStoreUtil.makeDBIDStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC); WritableDoubleDataStore lambda = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC, Double.POSITIVE_INFINITY); convertToPointerRepresentation(ids, heap, pi, lambda); return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, distQ.getDistanceFunction().isSquared(), coredists); }
/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, coredists);
/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, distQ.getDistanceFunction().isSquared(), coredists);
/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
return new PointerDensityHierarchyRepresentationResult(ids, pi, lambda, distQ.getDistanceFunction().isSquared(), coredists);
/** * Constructor. * * @param pointerresult Hierarchical result */ public Instance(PointerHierarchyRepresentationResult pointerresult) { this.ids = pointerresult.topologicalSort(); this.pi = pointerresult.getParentStore(); this.lambda = pointerresult.getParentDistanceStore(); this.pointerresult = pointerresult; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { this.coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } }
@Override public Clustering<DendrogramModel> run(Database database) { PointerHierarchyRepresentationResult pointerresult = algorithm.run(database); DBIDs ids = pointerresult.getDBIDs(); DBIDDataStore pi = pointerresult.getParentStore(); DoubleDataStore lambda = pointerresult.getParentDistanceStore(); DoubleDataStore coredist = null; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } Clustering<DendrogramModel> result = extractClusters(ids, pi, lambda, coredist); result.addChildResult(pointerresult); return result; }
@Override public Clustering<DendrogramModel> run(Database database) { PointerHierarchyRepresentationResult pointerresult = algorithm.run(database); DBIDs ids = pointerresult.getDBIDs(); DBIDDataStore pi = pointerresult.getParentStore(); DoubleDataStore lambda = pointerresult.getParentDistanceStore(); DoubleDataStore coredist = null; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } Clustering<DendrogramModel> result = extractClusters(ids, pi, lambda, coredist); result.addChildResult(pointerresult); return result; }
@Override public void processNewResult(ResultHierarchy hier, Result newResult) { ArrayList<PointerHierarchyRepresentationResult> hrs = ResultUtil.filterResults(hier, newResult, PointerHierarchyRepresentationResult.class); for(PointerHierarchyRepresentationResult pointerresult : hrs) { DBIDs ids = pointerresult.getDBIDs(); DBIDDataStore pi = pointerresult.getParentStore(); DoubleDataStore lambda = pointerresult.getParentDistanceStore(); DoubleDataStore coredist = null; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } Clustering<DendrogramModel> result = inner.extractClusters(ids, pi, lambda, coredist); pointerresult.addChildResult(result); } }
@Override public void processNewResult(ResultHierarchy hier, Result newResult) { ArrayList<PointerHierarchyRepresentationResult> hrs = ResultUtil.filterResults(hier, newResult, PointerHierarchyRepresentationResult.class); for(PointerHierarchyRepresentationResult pointerresult : hrs) { DBIDs ids = pointerresult.getDBIDs(); DBIDDataStore pi = pointerresult.getParentStore(); DoubleDataStore lambda = pointerresult.getParentDistanceStore(); DoubleDataStore coredist = null; if(pointerresult instanceof PointerDensityHierarchyRepresentationResult) { coredist = ((PointerDensityHierarchyRepresentationResult) pointerresult).getCoreDistanceStore(); } Clustering<DendrogramModel> result = inner.extractClusters(ids, pi, lambda, coredist); pointerresult.addChildResult(result); } }