Skip to content

Issue in the way all_knees and all_elbows are ordered #161

@leonfodoulian

Description

@leonfodoulian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions