Comments (4)
Hi @MitchellAcoustics, thanks for checking out the repo. The x and y values are interpolated and normalized before they are transformed, so it should handle the issue of unevenly spaced x value input. Does this example help answer any questions?
import numpy as np
import matplotlib.pyplot as plt
from kneed import KneeLocator
n = 50
x = np.geomspace(1, 256, num=n)
y = np.linspace(0, 1, num=n)
plt.scatter(x, y)
Kneed seems to find a reasonable knee point.
kneed = KneeLocator(x, y, curve='concave', direction='increasing')
print(kneed.knee)
46.883891195871875
kneed.plot_knee()
from kneed.
Hi Thanks for this great algorithm. However I am struggling to get it work when x becomes log(x). For example for your same above example, if I did below, the found knee point is at end point which is not correct.
import numpy as np
import matplotlib.pyplot as plt
from kneed import KneeLocator
n = 50
x = np.linspace(1, 256, num=n)
x1=np.log(x)
y = np.linspace(0, 1, num=n)
kneed = KneeLocator(x1, y, curve='convex', direction='increasing')
from kneed.
Hi
I keep playing with interpolation method, polynomial degree and sensitivity parameters and I found the results change a lot by changing these parameters. and the best result I got is still not optimal. Now my question is how do we select the parameters automatically? I am using this algorithm to detect elbow point automatically for any curve. Could you please help ? Thank you so much.
import numpy as np
import matplotlib.pyplot as plt
from kneed import KneeLocator
n = 50
x = np.linspace(1, 256, num=n)
x1=np.log(x)
y = np.linspace(0, 1, num=n)
kneed = KneeLocator(x1, y, S=1,curve='convex', direction='increasing',online=True,interp_method="polynomial",polynomial_degree=3)
print(kneed.knee)
kneed.plot_knee_normalized()
kneed.plot_knee()
from kneed.
If I may chime in, I think the issue is that only the y value is transformed.
In knee_locator.py, there is a transform_y function that handles the entire transform. I think this could be fixed by adding a transform_x function that handles an x transformation.
def transform_x(x: Iterable[float], direction: str, curve: str) -> float:
"""transform x to concave, increasing based on given direction and curve"""
# convert elbows to knees
if direction == "decreasing" and curve == "concave":
x = x.max() - x
elif direction == "increasing" and curve == "convex":
x = x.max() - x
return x
def transform_y(y: Iterable[float], direction: str, curve: str) -> float:
"""transform y to concave, increasing based on given direction and curve"""
# convert elbows to knees
if curve == "convex":
y = y.max() - y
return y
Then changing this part of the code
# Step 2: normalize values
self.x_normalized = self.__normalize(self.x)
self.y_normalized = self.__normalize(self.Ds_y)
# Step 3: Calculate the Difference curve
self.y_normalized = self.transform_y(
self.y_normalized, self.direction, self.curve
)
self.x_normalized = self.transform_x(
self.x_normalized, self.direction, self.curve
)
# normalized difference curve
from kneed.
Related Issues (20)
- IndexError: Line 271 HOT 1
- make matplotlib an extra dependency HOT 1
- can not detect knee/elbow point in python 3.9 HOT 2
- Documentation states default for online is True, but it is really False HOT 1
- How to use it with Multivariate X, Throwing interpolation axis Error HOT 1
- Ability to change title, and set xlabel and ylabel for visualization function HOT 3
- Issues about the online correction HOT 1
- GH Actions bug HOT 1
- Remove unnecessary warning HOT 2
- Add readthedocs.yaml file
- Remove travis badge from README HOT 1
- Update pythonpublish workflow
- Knee is NoneType with my specific set of points HOT 2
- Potentially wrong plot and/or knee identification HOT 4
- Problem with curves with multiple slopes HOT 3
- Unable to detect knee and elbow HOT 1
- Request: Documentation
- Implementation Detail HOT 1
- TypeError: transform_y() takes 3 positional arguments but 4 were given HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kneed.