kneed
kneed copied to clipboard
Issue in the way all_knees and all_elbows are ordered
Hi,
I think there is an issue in the way the knees and elbows are ordered when online = True
. I am using the kneed
package in R
. And the code below is reproducible:
# import kneed as kn
kn <- reticulate::import(module = "kneed")
# Compute kernel density estimates of mtcars$mpg
dens <- density(x = mtcars$mpg,
from = 19,
to = 45)
# Identify knees in the density distribution
kneed.res <- kn$KneeLocator(x = dens$x,
y = dens$y,
S = 1,
curve = "convex",
direction = "decreasing",
online = TRUE)
# Knee and elbow values are not ordered
kneed.res$all_knees
# {26.93737769080235, 19.0, 36.50293542074364}
kneed.res$all_elbows
# {26.93737769080235, 19.0, 36.50293542074364}
I have to mention that this is not a general observation, but I found it occurring in many of my implementations of the function.
Best, Leon