-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flow_Output.py
29 lines (22 loc) · 979 Bytes
/
Flow_Output.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
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, mean_absolute_error
# Read the dataset
df = pd.read_csv("D:\\UpSkillCampus Project11\\continuous_factory_process.csv")
# Separate features and target
X = df.drop(['time_stamp'], axis=1) # Remove the 'time_stamp' column
y = df['Stage2.Output.Measurement14.U.Setpoint']
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Create and train the linear regression model
model = LinearRegression()
model.fit(X_train, y_train)
# Make predictions on the test set
y_pred = model.predict(X_test)
# Calculate the mean squared error
mse = mean_squared_error(y_test, y_pred)
print('Mean Squared Error:', mse)
# Calculate the mean absolute error
mae = mean_absolute_error(y_test, y_pred)
print('Mean Absolute Error:', mae)