We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importnumpyasnpfromsklearn.linear_modelimportLinearRegressionPhysics=[15,12,8,8,7,7,7,6,5,3]History=[10,25,17,11,13,17,20,13,9,15]#Sample dataX=np.array(Physics).reshape((-1,1))y=np.array(History)#Create and train the modelmodel=LinearRegression()model.fit(X,y)#Get the slope (coefficient)slope=model.coef_[0]slope
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Correlation and Regression Lines - A Quick Recap #2
You are viewing a single comment's thread. Return to all comments →