Python script for linear regression on panda dataframe

0 votes
I have the following panda dataframe:

    value
0  4354
1  7556
2  609
3  7842

I need to perform linear regression on it. Can I have a python script for this purpose? Thank you
May 23, 2019 in Machine Learning by Ishaan
389 views

1 answer to this question.

0 votes

Use the following code:

from scipy import stats
slope, intercept, r_value, p_value, std_err = stats.linregress(df.index, df['value'])
df['linreg'] = intercept + slope * df.index

answered May 23, 2019 by Imran

Related Questions In Machine Learning

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Real world applications of Machine Learning

Few real-world applications of machine learning are  Have ...READ MORE

answered May 9, 2019 in Machine Learning by Jinu
163 views
0 votes
1 answer
0 votes
1 answer

What is rolling linear regression?

Rolling regression is the analysis of changing ...READ MORE

answered May 23, 2019 in Machine Learning by Jinu
504 views
0 votes
1 answer