Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ from sklearn.decomposition import PCA
|
|
8 |
import pickle
|
9 |
from tensorflow.keras.models import load_model
|
10 |
import pickle
|
|
|
11 |
|
12 |
|
13 |
|
@@ -27,7 +28,6 @@ def predict_ann(age, workclass, education, marital_status, occupation, relations
|
|
27 |
# with open('ann_model.pkl', 'rb') as ann_model_file:
|
28 |
# ann_model = pickle.load(ann_model_file)
|
29 |
scaler = StandardScaler()
|
30 |
-
X = scaler.fit_transform(fixed_features)
|
31 |
ann_model = load_model('ann_model.h5')
|
32 |
prediction = ann_model.predict(fixed_features)
|
33 |
# prediction = 1
|
@@ -48,7 +48,6 @@ def predict_rf(age, workclass, education, marital_status, occupation, relationsh
|
|
48 |
# with open('ann_model.pkl', 'rb') as ann_model_file:
|
49 |
# ann_model = pickle.load(ann_model_file)
|
50 |
scaler = StandardScaler()
|
51 |
-
X = scaler.fit_transform(fixed_features)
|
52 |
rf_model = pickle.load(open('rf_model.pkl', 'rb'))
|
53 |
prediction = rf_model.predict(fixed_features)
|
54 |
# prediction = 1
|
@@ -71,9 +70,9 @@ def predict_hb(age, workclass, education, marital_status, occupation, relationsh
|
|
71 |
scaler = StandardScaler()
|
72 |
X = scaler.fit_transform(fixed_features)
|
73 |
hb_model = pickle.load(open('hdbscan_model.pkl', 'rb'))
|
74 |
-
prediction =
|
75 |
# prediction = 1
|
76 |
-
return "
|
77 |
|
78 |
|
79 |
def cleaning_features(data,race):
|
@@ -222,8 +221,8 @@ hb_interface = gr.Interface(
|
|
222 |
|
223 |
|
224 |
interface = gr.TabbedInterface(
|
225 |
-
[ann_interface, rf_interface,hb_interface],
|
226 |
-
["ANN Model", "Random Forest Model","HDBScan Model"]
|
227 |
)
|
228 |
|
229 |
|
|
|
8 |
import pickle
|
9 |
from tensorflow.keras.models import load_model
|
10 |
import pickle
|
11 |
+
import hdbscan
|
12 |
|
13 |
|
14 |
|
|
|
28 |
# with open('ann_model.pkl', 'rb') as ann_model_file:
|
29 |
# ann_model = pickle.load(ann_model_file)
|
30 |
scaler = StandardScaler()
|
|
|
31 |
ann_model = load_model('ann_model.h5')
|
32 |
prediction = ann_model.predict(fixed_features)
|
33 |
# prediction = 1
|
|
|
48 |
# with open('ann_model.pkl', 'rb') as ann_model_file:
|
49 |
# ann_model = pickle.load(ann_model_file)
|
50 |
scaler = StandardScaler()
|
|
|
51 |
rf_model = pickle.load(open('rf_model.pkl', 'rb'))
|
52 |
prediction = rf_model.predict(fixed_features)
|
53 |
# prediction = 1
|
|
|
70 |
scaler = StandardScaler()
|
71 |
X = scaler.fit_transform(fixed_features)
|
72 |
hb_model = pickle.load(open('hdbscan_model.pkl', 'rb'))
|
73 |
+
prediction = hdbscan.approximate_predict(hb_model,fixed_features)
|
74 |
# prediction = 1
|
75 |
+
return f"Predicted Cluster (HDBSCAN): {prediction}"
|
76 |
|
77 |
|
78 |
def cleaning_features(data,race):
|
|
|
221 |
|
222 |
|
223 |
interface = gr.TabbedInterface(
|
224 |
+
[ann_interface, rf_interface, hb_interface],
|
225 |
+
["ANN Model", "Random Forest Model", "HDBScan Model"]
|
226 |
)
|
227 |
|
228 |
|