| import gradio as gr |
| import tensorflow as tf |
| import numpy as np |
|
|
| |
| 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 = np.array([[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][0] |
| result = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️" |
| return f"{result}" |
|
|
| |
| |
| salarybracket_ga = gr.Interface(fn=salarybracket, |
| inputs = [ |
| gr.Number(17, 90, label="Age [17 to 90]"), |
| gr.Number(0, 8, label="Workclass [0 to 8]"), |
| gr.Number(0, 15, label="Education [0 to 15]"), |
| gr.Number(1, 16, label="Education Num [1 to 16]"), |
| gr.Number(0, 6, label="Marital Status [0 to 6]"), |
| gr.Number(0, 14, label="Occupation [0 to 14]"), |
| gr.Number(0, 5, label="Relationship [0 to 5]"), |
| gr.Number(0, 4, label="Race [0 to 4]"), |
| gr.Number(0, 1, label="Gender [0 to 1]"), |
| gr.Number(0, 99999, label="Capital Gain [0 to 99999]"), |
| gr.Number(0, 4356, label="Capital Loss [0 to 4356]"), |
| gr.Number(1, 99, label="Hours per Week [1 to 99]"), |
| gr.Number(0, 40, label="Native Country [0 to 40]"), |
| ], |
| outputs="text", title="Salary Bracket Prediction - Income <=50k or >50K ", |
| 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 TensorFlow", |
| theme='dark' |
| ) |
|
|
| salarybracket_ga.launch(share=True,debug=True) |