I am struggling a bit with the logic.

I need to estimate growth based on historical data.

My data is basically composed of dates + a snapshot of disk usage.

date disk_usage growth
2001.01.01 520 NULL
2001.01.02 537 1.0327
2001.01.03 544 1.0130
2001.01.04 546 1.00367
2001.01.04 ... ...

I want to estimate the growth column to a point where I can use

disk_usage[T-1] * growth[T] = forecasted value

Data is pretty linear. So a linear model should do the job. When I do the regression in EXCEL the line looks pretty straight, not many outliers, no seasonality and the data looks stationary.

I need to do the regression in Python. When I use the statsmodel package I need to use a equation as a string :

import statsmodels.formula.api as smf

model = smf.ols('???', data=dt)

In the above, the ???, should it be growth ~ growth[T-1] or growth ~ rowIndex or maybe I should add another column which is days since the first date in the sample ?

UPDATE: I am not looking for anything too complex. Just a informed guess. This is not a critical component of our system and even if it is not 100% accurate, no one will suffer.


1 Answer 1


If you want to use regression, I recommend using the scikit-learn library. It's quite straightforward:


import numpy as np
from sklearn.linear_model import LinearRegression
X = np.array(your_data_x)
Y = np.array(your_data_y)
model = LinearRegression().fit(X, Y)

prediction = model.predict(np.array(new_entry))
  • 1
    $\begingroup$ downvoted because it doesn't answer the question asked $\endgroup$ Sep 21 at 9:04
  • $\begingroup$ "I need to do the regression in Python" " I am not looking for anything too complex" I provided you an answer which is simple and does regression. @user91991993 $\endgroup$
    – alienflow
    Sep 21 at 21:26
  • $\begingroup$ I agree that the question asks for a Python solution and you address that. The difficulty is that this is not a site about how to do things in Python (or any other specific programming language). $\endgroup$
    – whuber
    Sep 21 at 21:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.