question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Knee point in logistic-like curve

See original GitHub issue

Hi, I have a curve that looks like a logistic function (data array below):

Figure_1

I need to find the knee where it starts to grow, which would be around ~75, but I can’t seem to be able to do it. I’ve tried all the combinations of the curve, direction parameters to no avail.

Is kneed capable of doing this?

Cheers

[array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11., 12., 13.,
       14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.,
       27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39.,
       40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 51., 52.,
       53., 54., 55., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65.,
       66., 67., 68., 69., 70., 71., 72., 73., 74., 75., 76., 77., 78.,
       79., 80., 81., 82., 83., 84., 85., 86., 87., 88., 89., 90., 91.,
       92., 93., 94., 95., 96., 97., 98.]), array([2.00855493e-45, 1.10299045e-43, 4.48168384e-42, 1.22376580e-41,
       5.10688883e-40, 1.18778110e-38, 5.88777891e-35, 4.25317895e-34,
       4.06507035e-33, 6.88084518e-32, 2.99321831e-31, 1.13291723e-30,
       1.05244482e-28, 2.67578448e-27, 1.22522190e-26, 2.36517846e-26,
       8.30369408e-26, 1.24303033e-25, 2.27726918e-25, 1.06330422e-24,
       5.55017673e-24, 1.92068553e-23, 3.31361011e-23, 1.13575247e-22,
       1.75386416e-22, 6.52680518e-22, 2.05106011e-21, 6.37285545e-21,
       4.16125535e-20, 1.12709507e-19, 5.75853420e-19, 1.73333796e-18,
       2.70099890e-18, 7.53254646e-18, 1.38139433e-17, 3.60081965e-17,
       8.08419977e-17, 1.86378584e-16, 5.36224556e-16, 8.89404640e-16,
       2.34045104e-15, 4.72168880e-15, 6.84378992e-15, 2.26898430e-14,
       3.10087652e-14, 2.78081199e-13, 1.06479577e-12, 2.81002203e-12,
       4.22067092e-12, 9.27095863e-12, 1.54519738e-11, 4.53347819e-11,
       1.35564441e-10, 2.35242087e-10, 4.45253545e-10, 9.78613696e-10,
       1.53140922e-09, 2.81648560e-09, 6.70890436e-09, 1.49724785e-08,
       5.59553565e-08, 1.39510811e-07, 7.64761811e-07, 1.40723957e-06,
       4.97638863e-06, 2.12817943e-05, 3.26471410e-05, 1.02599591e-04,
       3.18774179e-04, 5.67297630e-04, 9.22732716e-04, 1.17445643e-03,
       3.59279384e-03, 3.61936491e-02, 6.39493416e-02, 1.29304829e-01,
       1.72272215e-01, 3.46945901e-01, 5.02826602e-01, 6.24800042e-01,
       7.38412957e-01, 7.59931663e-01, 7.73374421e-01, 7.91421897e-01,
       8.29325597e-01, 8.57718637e-01, 8.73286061e-01, 8.77056835e-01,
       8.93173768e-01, 9.05435646e-01, 9.17217910e-01, 9.19119179e-01,
       9.24810910e-01, 9.26306908e-01, 9.28621233e-01, 9.33855835e-01,
       9.37263027e-01, 9.41651642e-01])]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arvkevicommented, Jul 26, 2020

Sure, @Gabriel-p – I’ve been meaning to make proper documentation for this repo for a year now… I hope this explanation will do, for now.

When online=False the first knee point identified is returned regardless of whether it’s the local maxima on the difference curve or the global maxima. So the algorithm stops early. When online=True, kneed runs in online mode and “corrects” itself by continuing to overwrite any previously identified knees.

Here’s a quick example to show the usage of the parameter.

online=False:

from kneed import KneeLocator
y = [0, 1.0, 1.5, 1.8, 1.9, 2.0, 3.5, 5.0, 7.0, 9.0, 9.5, 9.75, 9.9, 10]
kl = KneeLocator(range(len(y)), y, curve="concave", direction="increasing", online=False)
kl.plot_knee_normalized()

image

online=True:

kl = KneeLocator(range(len(y)), y, curve="concave", direction="increasing", online=True)
kl.plot_knee_normalized()

image

1reaction
arvkevicommented, Jul 25, 2020

Hey @Gabriel-p sorry for the delay, I have a working branch and an open PR that identifies the knee in your example at x = 73 using the following arguments:

kl = KneeLocator(x, y, curve="convex", direction="increasing", online=True)

You can try installing from source for now until I get this merged and cut a new release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a formal reason for identifying and using "knee/elbow ...
Your intuition about optimization is right. The elbow/knee considered as the point where the independant variable(s) will either start to or ...
Read more >
Identification and machine learning prediction of knee-point ...
Using capacity degradation data, we propose a robust method to identify the knee-point within capacity fade curves. In a new approach to knee...
Read more >
Knee of a curve - Wikipedia
In mathematics, a knee of a curve is a point where the curve visibly bends, specifically from high slope to low slope or...
Read more >
( a ) Linear regression models linking the knee-point to cycle ...
( a ) Linear regression models linking the knee-point to cycle life and and knee-onset to cycle life, both linear with 95% confidence...
Read more >
Algorithm to Determine the Knee Point on Capacity Fade ...
This paper provides a definition of the knee point which can be used as a degradation metric, and develops an algorithm to identify...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found