From cf333431ebcf54c2faf32db20866d9c5558bb64e Mon Sep 17 00:00:00 2001 From: ~Chiluka Akshitha <120377576+AKSHITHA-CHILUKA@users.noreply.github.com> Date: Sat, 27 Jul 2024 15:52:51 +0530 Subject: [PATCH 1/2] Create train_model.py --- Hedging with Real Estate/train_model.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Hedging with Real Estate/train_model.py diff --git a/Hedging with Real Estate/train_model.py b/Hedging with Real Estate/train_model.py new file mode 100644 index 00000000..9bcf1c3a --- /dev/null +++ b/Hedging with Real Estate/train_model.py @@ -0,0 +1,17 @@ +import pandas as pd +from sklearn.model_selection import train_test_split +from sklearn.linear_model import LinearRegression +import joblib + +def train_model(df): + X = df.drop('target', axis=1) + y = df['target'] + 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) + joblib.dump(model, 'path/to/model.pkl') + return model + +if __name__ == "__main__": + df = pd.read_csv('path/to/features_data.csv') + model = train_model(df) From 948f9d11daf098184574cbcaa86bafcacd40f317 Mon Sep 17 00:00:00 2001 From: ~Chiluka Akshitha <120377576+AKSHITHA-CHILUKA@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:03:53 +0530 Subject: [PATCH 2/2] Update train_model.py --- Hedging with Real Estate/train_model.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Hedging with Real Estate/train_model.py b/Hedging with Real Estate/train_model.py index 9bcf1c3a..d971c3ef 100644 --- a/Hedging with Real Estate/train_model.py +++ b/Hedging with Real Estate/train_model.py @@ -2,7 +2,6 @@ from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression import joblib - def train_model(df): X = df.drop('target', axis=1) y = df['target'] @@ -11,7 +10,6 @@ def train_model(df): model.fit(X_train, y_train) joblib.dump(model, 'path/to/model.pkl') return model - if __name__ == "__main__": df = pd.read_csv('path/to/features_data.csv') model = train_model(df)