I have the following df (I will attach it in the post):
Then I draw two columns, the one called Price and the one called OG. And it has shown something like this:
So I want to get the tangent point (x,y) that optimizes the curve. In the image I can see that it is close to the coordinate (80, 0.160), but how can I get this coordinate automatically, considering that the curve might change in the future?
Thanks in advance!
Here the df in .csv format:
,INCREASE [%],PRICE,INCREASE,QTY,GPS,NNS,OG [%] 0,0.0,47.69,0.0,239032932.10219583,11399480531.953718,9649069936.361042, 1,0.1,52.458999999999996,4.769,267545911.79200616,14035190986.69685,11961949944.986732,0.27315694384293565 2 ,0.2,57.227999999999994,9.538,296058891.48181653,16942858241.721395,14546786753.89384,0.24307636032561325 3,0.30000000000000004,61.997,14.307000000000002,324571871.1716268,20122482297.027348,17403580363.082355,0.21857913428577896 4,0.4,66.76599999999999,19.076,353084850.8614371,23574063152.614704,20532330772.55227,0.198325906714522 5,0.5,71.535, 23.845,381597830.5512475,27297600808.483486,23933037982.30361,0.18134997420002735 6,0.6000000000000001,76.304,28.614000000000004,410110810.2410579,31293095264.633682,27605701992.33637,0.16694472549220507 7,0.7000000000000001,81.07300000000001,33.383,438623789.93086815,35560546521.06528,31550322802.650528,0.1545858626459231 8,0.8,85.842,38.152,467136769.6206784,40099954577.778275,35766900413.246086,0.14387833953735796 9,0.9,90.61099999999999,42.921,495649749.3104888,44911319434.7727,40255434824.12307,0.13452003951711053 10,1.0,95.38,47.69,524162729.0002991,49994641092.04852,45015926035.28145,0.12627665505254082 11,1.1,100.149,52.459,552675708.6901095,55349919549.605774,50048374046.72126,0.11896408514089048 12,1.2000000000000002,104.918,57.22800000000001,581188688.3799199,60977154807.444435,55352778858.44248,0.11243592554246645 13,1.3,109.687,61.997,609701668.0697302,66876346865.56449,60929140470.44511,0.10657445172186328 14,1.4000000000000001,114.456 ,66.766,638214647.7595404,73047495723.96596,66777458882.729126,0.10128402946033532 15,1.5,119.225,71.535,666727627.4493507,79490601382.64883,72897734095.29456,0.09648623602161768 16,1.6,123.994,76.304,695240607.1391611,86205663841.61314,79289966108.14143,0.09211620281895366 17,1.7000000000000002,128.763,81.07300000000001,723753586.8289715,93192683100.85886,85954154921.26971,0.08811984166718287 18,1.8,133.53199999999998,85.842,752266566.5187817,100451659160.38594,92890300534.67935,0.08445171808362244 19,1.9000000000000001, 138.301,90.611,780779546.208592,107982592020.19447,100098402948.37045,0.08107340396640193 20,2.0,143.07,95.38,809292525.8984023,115785481680.28442,107578462162.34296,0.0779521893482613608445171808362244 19,1.9000000000000001,138.301,90.611,780779546.208592,107982592020.19447,100098402948.37045,0.08107340396640193 20,2.0,143.07,95.38,809292525.8984023,115785481680.28442,107578462162.34296,0.0779521893482613608445171808362244 19,1.9000000000000001,138.301,90.611,780779546.208592,107982592020.19447,100098402948.37045,0.08107340396640193 20,2.0,143.07,95.38,809292525.8984023,115785481680.28442,107578462162.34296,0.07795218934826136
Good day,
The library
kneed
can help you to obtain the inflection point, you must keep in mind that it is important to know if you are looking for aknee
or aelbow
, the type of curve and the direction (I recommend you read the documentation, it has good examples for different scenarios)Create a
dataframe
with the PRICE and OG columns from your data to simplify the example (File sample2.csv)This returns the following graph:
To obtain the numerical value you can use the method
knee
orelbow
, for the X coordinate andknee_y
orelbow_y
for the Y coordinateThis returns: