-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathML MODEL.py
34 lines (22 loc) · 937 Bytes
/
ML MODEL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
data = pd.read_csv('datasets\Thermal_powerplant.csv')
X = data.iloc[:, :-1]
y = data.iloc[:, -1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
mse = mean_squared_error(y_test, y_pred)
print(f"Mean Squared Error: {mse}")
coefficients = model.coef_
intercept = model.intercept_
print(f"Coefficients: {coefficients}")
print(f"Intercept: {intercept}")
import numpy as np
x_input = [float(x) for x in input("Enter values for all features separated by spaces: ").split()]
x_input = np.array(x_input).reshape(1, -1)
y_output = model.predict(x_input)
print(f"The predicted output is {y_output[0]}")