Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<br>
plt.legend(loc="upper right")
plt.title("Residual Errors")
plt.show()

```
## Output:
<img width="1388" height="740" alt="image" src="https://github.com/user-attachments/assets/5cb68c09-7664-48eb-8d18-129fdef02a2e" />
<img width="1381" height="649" alt="image" src="https://github.com/user-attachments/assets/37a4e01e-3c93-4025-8a82-34846f700957" />

## Result
Thus the multivariate linear regression is implemented and predicted the output using python program.
Thus the multivariate linear regression is implemented and predicted the output using python program.