Code Monkey home page Code Monkey logo

kneedle's Introduction

Kneedle

Implementation of knee/elbow finding algorithm 'Kneedle' in C#.

Calculates knee points using the Kneedle algorithm. Returns the x value corresponding to the knee point when successful, null otherwise.

Contains only batch mode implementation right now. Contributoins welcome for online/streaming implementation, as well as any other improvements!

Reference

"Finding a ‘kneedle’ in a haystack: Detecting knee points in system behavior. "
Satopaa, V and Albrecht, J and Irwin, D and Raghavan, B
31-st International Conference on Distributed Computing Systems
2011

https://raghavan.usc.edu/papers/kneedle-simplex11.pdf

Usage

var y = new double[] { 1, 1, 0.894, 0.864, 0.859, 0.856, 0.852, 0.851, 0.849, 0.848, 0.847, 0.845 };
var x = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

var k1 = KneedleAlgorithm.CalculateKneePoints(x, y, CurveDirection.Decreasing, Curvature.Counterclockwise, forceLinearInterpolation: false); 
// Returns 4

var k2 = KneedleAlgorithm.CalculateKneePoints(x, y, CurveDirection.Decreasing, Curvature.Clockwise, forceLinearInterpolation: false);
// Returns 2

Inputs

x: X axis values of the points. Points must be sorted in ascending order w.r.t. X axis.

y: Y axis values of the points.

direction: If the curve is increasing or decreasing. Make sure to set this value according to the input curve.

concavity: Whether the curve has positive or negative curvature. In other words, concave or convex. Whether the tangent rotates clockwise or counterclockwise. Make sure to set this value according to the input curve.

sensitivity: Adjusts the knee detection threshold. Defaults to 1 as per the paper.

forceLinearInterpolation: Interpolation is done using robust cubic splines. For some inputs, spline can overshoot. This param forces linear interpolation instead of cubic spline.

Output

Returns the x value corresponding to the knee point.

Can return null when the algorithm fails to identify a knee/elbow for various reasons:

  • the number of data points is too small
  • there are no local maxima on the diffs, which means either the curve is a line, or the parameters provided are incompatible with the curve

Dependencies

MathNet.Numerics from NuGet.

kneedle's People

Contributors

dc0d32 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.