elki-project / elki

ELKI Data Mining Toolkit
https://elki-project.github.io/
GNU Affero General Public License v3.0
780 stars 321 forks source link

PrimsMinimumSpanningTree ArrayIndexOutOfBoundsException #46

Closed neilireson closed 6 years ago

neilireson commented 6 years ago

I'm getting an exception, probably because my data set is too small for HDBSCAN (there are only two data points in in the particular data set when the exception is thrown). The data set works fine with the other Clustering algorithms.

I can catch the Exception in my code but perhaps it would be best if it were caught within ELKI.

  clustering = new ELKIBuilder<>(HDBSCANHierarchyExtraction.class) //
   .with(HDBSCANHierarchyExtraction.Parameterizer.MINCLUSTERSIZE_ID, minPoints) //
   .with(HDBSCANLinearMemory.Parameterizer.MIN_PTS_ID, minPoints) //
   .with(AbstractAlgorithm.ALGORITHM_ID, HDBSCANLinearMemory.class) //
   .build().run(db);

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at de.lmu.ifi.dbs.elki.math.geometry.PrimsMinimumSpanningTree.processDense(PrimsMinimumSpanningTree.java:170)
    at de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.HDBSCANLinearMemory.run(HDBSCANLinearMemory.java:122)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm.run(AbstractAlgorithm.java:87)
    at de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.HDBSCANLinearMemory.run(HDBSCANLinearMemory.java:79)
    at de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.HDBSCANHierarchyExtraction.run(HDBSCANHierarchyExtraction.java:129)
    at uk.ac.shef.wit.active10.CreateStaypoints.cluster(CreateStaypoints.java:708)
    at uk.ac.shef.wit.active10.CreateStaypoints.main(CreateStaypoints.java:1151
kno10 commented 6 years ago

Thanks for reporting. Fixed. Ignoring / avoiding errors is usually not the best thing; this is a proper fix in PrimsMinimumSpanningTree.