From 76321eeb59c4b11128df4e5326f43218336a9ecc Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Tue, 26 Sep 2023 04:47:37 +0530 Subject: [PATCH] save a load from model --- .gitignore | 3 ++- scripts/logistic.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3b81fe3..baba9e6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ env/ *.xlsx *.csv *.json -cloud-functions/python/functions/__pycache__/ \ No newline at end of file +cloud-functions/python/functions/__pycache__/ +*.pkl diff --git a/scripts/logistic.py b/scripts/logistic.py index 2a51665..ad8b928 100644 --- a/scripts/logistic.py +++ b/scripts/logistic.py @@ -3,6 +3,7 @@ from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import LabelEncoder from sklearn.metrics import accuracy_score, classification_report +import pickle data = pd.read_excel('/Users/apple/Downloads/21092023-July_Sept.xlsx', sheet_name="op") data = data.dropna() @@ -29,3 +30,14 @@ classification_report_result = classification_report(y_test, y_pred) print(f"Accuracy: {accuracy}") print("Classification Report:") print(classification_report_result) + +# with open('logistic_regression_model.pkl', 'wb') as model_file: +# pickle.dump(model, model_file) + + +# with open('logistic_regression_model.pkl', 'rb') as model_file: +# loaded_model = pickle.load(model_file) + +# new_data = pd.DataFrame({'Age': [30], 'Gender': ['MALE'], 'Caste': ['SC'], 'Category': [''], 'Marital Status': ['Single']}) +# predicted_result = loaded_model.predict(new_data) +# print(predicted_result) \ No newline at end of file