jenkspy
jenkspy copied to clipboard
Duplicate breaks returned for given use-case
Hi,
I have a sequence of numbers (note that the value 1 appears twice) that when passed to jenks_breaks (with nb_class=9) returns a list of breaks with one of the breaks duplicated (i.e. 1 is returned twice).
Is this expected behavior?
import jenkspy
a=[10,9,8,7,6,5,4,3,2,1,1]
print(jenkspy.jenks_breaks(a, nb_class=9))
[1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0]
Thank you!
I have the same problem. It can be solved if I drop duplicates from the list before using it, but I'm not sure if this will afftect the behaviour of the function
Jenkspy returns a list a bounds. The first value is the lower bound, inclusive, of the first cluster. The other values are the upper bounds, inclusive, of each cluster.
In your case, it means that the first cluster contains the two 1 values and it looks perfectly fine.
Other implementations, such as mapclassify.FisherJenks exhibits the same behavior
See also #22 in which the correct expected classes (in the test case posted by the OP) are [-2.0, -2.0, 1.0].