save a load from model

This commit is contained in:
Pritimay Sarkar
2023-09-26 04:47:37 +05:30
parent 11ca03861e
commit 76321eeb59
2 changed files with 14 additions and 1 deletions

3
.gitignore vendored
View File

@@ -4,4 +4,5 @@ env/
*.xlsx
*.csv
*.json
cloud-functions/python/functions/__pycache__/
cloud-functions/python/functions/__pycache__/
*.pkl

View File

@@ -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)