hellojj7 commited on
Commit
527cac6
1 Parent(s): 6c92ce2
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from sklearn.model_selection import train_test_split
3
+ from sklearn.linear_model import LogisticRegression
4
+ from sklearn.preprocessing import StandardScaler
5
+ from sklearn.pipeline import make_pipeline
6
+ import pickle
7
+
8
+ url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv"
9
+ names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
10
+ dataframe = pd.read_csv(url, names=names)
11
+
12
+ X = dataframe.iloc[:, :-1].values
13
+ Y = dataframe.iloc[:, -1].values
14
+
15
+ X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33, random_state=7)
16
+
17
+ # Updated model with StandardScaler and increased max_iter
18
+ model = make_pipeline(StandardScaler(), LogisticRegression(max_iter=1000))
19
+
20
+ model.fit(X_train, Y_train)
21
+
22
+ # Save the model to disk
23
+ filename = 'finalized_model.sav'
24
+ pickle.dump(model, open(filename, 'wb'))
25
+
26
+ # Load the model from disk
27
+ loaded_model = pickle.load(open(filename, 'rb'))
28
+ result = loaded_model.score(X_test, Y_test)
29
+ print(result)