Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load the pickled model
|
5 |
+
with model = tf.keras.models.load_model("census.h5")
|
6 |
+
|
7 |
+
# Define the function for making predictions
|
8 |
+
def salarybracket(age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country):
|
9 |
+
inputs = [[age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country]]
|
10 |
+
prediction = model.predict(inputs)
|
11 |
+
prediction_value = prediction[0]
|
12 |
+
|
13 |
+
# Categorize prediction_value
|
14 |
+
if prediction_value == 0:
|
15 |
+
result = "Income_bracket lesserthan or equal to 50K "
|
16 |
+
else:
|
17 |
+
result = "Income_bracket greater than to 50K"
|
18 |
+
|
19 |
+
return f"Income_bracket Prediction: {prediction_value} \n\nResult: {result}"
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
# Create the Gradio interface
|
24 |
+
cerviccancer_ga = gr.Interface(fn=cerviccancer,
|
25 |
+
inputs = [
|
26 |
+
gr.Number(13.0, 84.0, label="Age: [13 to 84]"),
|
27 |
+
gr.Number(1.0, 28.0, label="workclass: [1 to 28]"),
|
28 |
+
gr.Number(10.0, 32.0, label="education: [10 to 32]"),
|
29 |
+
gr.Number(0.0, 11.0, label="education_num: [0 to 11]"),
|
30 |
+
gr.Number(0.0, 1.0, label="marital_status: [0 or 1]"),
|
31 |
+
gr.Number(0.0, 37.0, label="occupation: [0 to 37]"),
|
32 |
+
gr.Number(0.0, 37.0, label="relationship: [0 to 37]"),
|
33 |
+
gr.Number(0.0, 1.0, label="race: [0 or 1]"),
|
34 |
+
gr.Number(0.0, 30.0, label="gender: [0 to 30]"),
|
35 |
+
gr.Number(0.0, 1.0, label="capital_gain: [0 or 1]"),
|
36 |
+
gr.Number(0.0, 19.0, label="capital_loss: [0.0 19.0]"),
|
37 |
+
gr.Number(0.0, 1.0, label="hours_per_week: [0 or 1]"),
|
38 |
+
gr.Number(0.0, 1.0, label="native_country: [0 or 1]"),
|
39 |
+
],
|
40 |
+
outputs="text", title="Cervical Cancer Risk Prediction",
|
41 |
+
examples = [
|
42 |
+
[75,0,0,6,6,0,2,1,0,0,0,1,3,0,0],
|
43 |
+
[25,4,11,9,2,13,2,4,0,0,0,48,38,1,1],
|
44 |
+
[29,4,1,7,4,3,3,2,1,0,0,40,14,0,0],
|
45 |
+
[51,5,12,14,2,4,0,4,1,15024,0,50,38,1,1],
|
46 |
+
[66,0,15,10,2,0,0,4,1,0,1825,40,38,1,1],
|
47 |
+
],
|
48 |
+
description="Predicting Income_bracket Prediction Using Machine Learning",
|
49 |
+
theme='dark'
|
50 |
+
)
|
51 |
+
|
52 |
+
cerviccancer_ga.launch(share=True,debug=True)
|