|
import gradio as gr |
|
import tensorflow as tf |
|
|
|
|
|
model = tf.keras.models.load_model("census.h5") |
|
|
|
|
|
def salarybracket(age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country): |
|
inputs = [[age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country]] |
|
prediction = model.predict(inputs) |
|
prediction_value = prediction[0] |
|
|
|
|
|
if prediction_value == 0: |
|
result = "Income_bracket lesserthan or equal to 50K " |
|
else: |
|
result = "Income_bracket greater than to 50K" |
|
|
|
return f"Income_bracket Prediction: {prediction_value} \n\nResult: {result}" |
|
|
|
|
|
|
|
|
|
cerviccancer_ga = gr.Interface(fn=cerviccancer, |
|
inputs = [ |
|
gr.Number(13.0, 84.0, label="Age: [13 to 84]"), |
|
gr.Number(1.0, 28.0, label="workclass: [1 to 28]"), |
|
gr.Number(10.0, 32.0, label="education: [10 to 32]"), |
|
gr.Number(0.0, 11.0, label="education_num: [0 to 11]"), |
|
gr.Number(0.0, 1.0, label="marital_status: [0 or 1]"), |
|
gr.Number(0.0, 37.0, label="occupation: [0 to 37]"), |
|
gr.Number(0.0, 37.0, label="relationship: [0 to 37]"), |
|
gr.Number(0.0, 1.0, label="race: [0 or 1]"), |
|
gr.Number(0.0, 30.0, label="gender: [0 to 30]"), |
|
gr.Number(0.0, 1.0, label="capital_gain: [0 or 1]"), |
|
gr.Number(0.0, 19.0, label="capital_loss: [0.0 19.0]"), |
|
gr.Number(0.0, 1.0, label="hours_per_week: [0 or 1]"), |
|
gr.Number(0.0, 1.0, label="native_country: [0 or 1]"), |
|
], |
|
outputs="text", title="Cervical Cancer Risk Prediction", |
|
examples = [ |
|
[75,0,0,6,6,0,2,1,0,0,0,1,3,0,0], |
|
[25,4,11,9,2,13,2,4,0,0,0,48,38,1,1], |
|
[29,4,1,7,4,3,3,2,1,0,0,40,14,0,0], |
|
[51,5,12,14,2,4,0,4,1,15024,0,50,38,1,1], |
|
[66,0,15,10,2,0,0,4,1,0,1825,40,38,1,1], |
|
], |
|
description="Predicting Income_bracket Prediction Using Machine Learning", |
|
theme='dark' |
|
) |
|
|
|
cerviccancer_ga.launch(share=True,debug=True) |