title: find the "elbow point" on an optimization curve with Python
body: <p>i have a list of points which are the inertia values of a kmeans algorithm.<br>
  To determine the optimum amount of clusters i need to find the point, where this curve starts to flatten.  </p>
  
  <p><strong>Data example</strong></p>
  
  <p>Here is how my list of values is created and filled:</p>
  
  <pre><code>sum_squared_dist = []
  K = range(1,50)
  for k in K:
      km = KMeans(n_clusters=k, random_state=0)
      km = km.fit(normalized_modeling_data)
      sum_squared_dist.append(km.inertia_)
  
  print(sum_squared_dist)
  </code></pre>
  
  <p>How can i find a point, where the pitch of this curve increases (the curve is falling, so the first derivation is negative)?</p>
  
  <p><strong>My approach</strong></p>
  
  <pre><code>derivates = []
  for i in range(len(sum_squared_dist)):
      derivates.append(sum_squared_dist[i] - sum_squared_dist[i-1])
  </code></pre>
  
  <p>I want to find the optimum number of clusters any given data using the elbow method. Could someone help me how i can find the point where the list of the inertia values starts to flatten?</p>
  
  <p><strong>Edit</strong><br>
  Datapoints:</p>
  
  <pre><code>[7342.1301373073857, 6881.7109460930769, 6531.1657905495022,  
  6356.2255554679778, 6209.8382535595829, 6094.9052166741121, 
  5980.0191582610196, 5880.1869867848218, 5779.8957906367368, 
  5691.1879324562778, 5617.5153566271356, 5532.2613232619951, 
  5467.352265375117, 5395.4493783888756, 5345.3459908298091, 
  5290.6769823693812, 5243.5271656371888, 5207.2501206569532, 
  5164.9617535255456]
  </code></pre>
  
  <p>Graph:
  <a href="https://i.stack.imgur.com/gRryK.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/gRryK.jpg" alt="graph"></a></p>