Skip to content

Instantly share code, notes, and snippets.

@dottyz
Created May 2, 2019 18:45
Show Gist options
  • Save dottyz/1bbd0fe14a542c94c6db5ff8321ac5af to your computer and use it in GitHub Desktop.
Save dottyz/1bbd0fe14a542c94c6db5ff8321ac5af to your computer and use it in GitHub Desktop.
def logistic_growth(x, k, x0):
return 1 / (1 + np.exp(-k*(x - x0)))
data['Cummulative Trips'] = data['Casual Trips'].cumsum()
data['Percentage Trips'] = data['Cummulative Trips'] / data['Casual Trips'].sum()
x = data['Mean Temp'].values
y = data['Percentage Trips'].values
popt, pcov = curve_fit(logistic_growth, x, y, maxfev=2000)
y_fit = logistic_growth(x, *popt)
kneedle = KneeLocator(x=x, y=y_fit, curve='convex', direction='increasing')
knee_start = kneedle.knee
print(knee_start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment