Last active
December 18, 2020 07:29
-
-
Save nithyadurai87/406747e718d04a4bc339f740b5f9de62 to your computer and use it in GitHub Desktop.
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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