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

Transform Your Career with AI, Enroll now in AI for Startup certification today!

May 23, 2019 in Machine Learning by Ishaan
1,886 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

bias and variance calculation for linear regression

Evaluation of Variance: variance = np.var(prediction) # Where ...READ MORE

answered Mar 2, 2022 in Machine Learning by Nandini
• 5,480 points
1,774 views
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 10, 2019 in Machine Learning by Jinu
782 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
1,953 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP