From a77f979952d6bde0b1fb745a25bfc9c9356072a6 Mon Sep 17 00:00:00 2001 From: "S.Priyadharshini" Date: Wed, 11 Mar 2026 13:35:41 +0530 Subject: [PATCH] Add multivariate linear regression example to README Added Python code for multivariate linear regression example and updated output section with images. --- README.md | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 18362d83..7d87895d 100644 --- a/README.md +++ b/README.md @@ -22,18 +22,45 @@ To write a python program to implement multivariate linear regression and predic ## Program: ``` +import matplotlib.pyplot as plt +import numpy as np +from sklearn import linear_model +from sklearn.datasets import load_diabetes +from sklearn.model_selection import train_test_split +# Load dataset +data = load_diabetes() +X = data.data +y = data.target +# Split dataset +X_train, X_test, y_train, y_test = train_test_split( + X, y, test_size=0.4, random_state=1 +) +# Model +reg = linear_model.LinearRegression() +reg.fit(X_train, y_train) +print("Coefficients:", reg.coef_) +print("Variance score:", reg.score(X_test, y_test)) +plt.scatter(reg.predict(X_train), reg.predict(X_train) - y_train, + color="green", s=10, label="Train data") -``` -## Output: +plt.scatter(reg.predict(X_test), reg.predict(X_test) - y_test, + color="blue", s=10, label="Test data") -### Insert your output +plt.hlines(y=0, xmin=0, xmax=400, linewidth=2) -
+plt.legend(loc="upper right") +plt.title("Residual Errors") +plt.show() + +``` +## Output: +image +image ## Result -Thus the multivariate linear regression is implemented and predicted the output using python program. \ No newline at end of file +Thus the multivariate linear regression is implemented and predicted the output using python program.