Instantly share code, notes, and snippets.

Last active December 18, 2020 07:29
Star You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 from sklearn.linear_model import LinearRegression import numpy as np x = [[6], [8], [10], [14], [18]] y = [[7], [9], [13], [17.5], [18]] model = LinearRegression() model.fit(x,y) print ("Residual sum of squares = ",np.mean((model.predict(x)- y) ** 2)) print ("Variance = ",np.var([6, 8, 10, 14, 18], ddof=1)) print ("Co-variance = ",np.cov([6, 8, 10, 14, 18], [7, 9, 13, 17.5, 18])[0][1]) print ("X_Mean = ",np.mean(x)) print ("Y_Mean = ",np.mean(y))

### myselfmuthusamy commented Dec 18, 2020

print ("Variance = ",np.var([6, 8, 10, 14, 18], ddof=1))
print ("Co-variance = ",np.cov([6, 8, 10, 14, 18], [7, 9, 13, 17.5, 18])[0][1])

I'm new to Machine Learning, just started from your book. Wanted to understand the ddof in variance and [0], [1] in covariance