Parthebhan
commited on
Commit
•
2206a9e
1
Parent(s):
7131760
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ mapping = {
|
|
18 |
}
|
19 |
|
20 |
# Define the function for making predictions
|
21 |
-
def salarybracket(age, workclass, education, marital_status, occupation, relationship, race, gender, native_country):
|
22 |
# Get the value associated with the selected label
|
23 |
workclass_value = next((v for k, v in mapping['workclass'].items() if k == workclass), None)
|
24 |
education_value = next((v for k, v in mapping['education'].items() if k == education), None)
|
@@ -29,7 +29,7 @@ def salarybracket(age, workclass, education, marital_status, occupation, relatio
|
|
29 |
gender_value = next((v for k, v in mapping['gender'].items() if k == gender), None)
|
30 |
native_country_value = next((v for k, v in mapping['native_country'].items() if k == native_country), None)
|
31 |
|
32 |
-
inputs = np.array([[age, workclass_value, education_value, marital_status_value, occupation_value, relationship_value, race_value, gender_value, native_country_value]])
|
33 |
prediction = model.predict(inputs)
|
34 |
prediction_value = prediction[0][0] # Assuming the prediction is a scalar
|
35 |
result = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️"
|
@@ -49,12 +49,16 @@ salarybracket_ga = gr.Interface(fn=salarybracket,
|
|
49 |
gr.Slider(17, 90, label="Age"),
|
50 |
gr.Dropdown(dropdown_options['workclass'], label="Workclass"),
|
51 |
gr.Dropdown(dropdown_options['education'], label="Education"),
|
|
|
52 |
gr.Dropdown(dropdown_options['marital_status'], label="Marital Status"),
|
53 |
gr.Dropdown(dropdown_options['occupation'], label="Occupation"),
|
54 |
gr.Dropdown(dropdown_options['relationship'], label="Relationship"),
|
55 |
gr.Dropdown(dropdown_options['race'], label="Race"),
|
56 |
gr.Dropdown(dropdown_options['gender'], label="Gender"),
|
57 |
-
gr.
|
|
|
|
|
|
|
58 |
],
|
59 |
outputs="text",
|
60 |
title="Salary Bracket Prediction",
|
|
|
18 |
}
|
19 |
|
20 |
# Define the function for making predictions
|
21 |
+
def salarybracket(age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country):
|
22 |
# Get the value associated with the selected label
|
23 |
workclass_value = next((v for k, v in mapping['workclass'].items() if k == workclass), None)
|
24 |
education_value = next((v for k, v in mapping['education'].items() if k == education), None)
|
|
|
29 |
gender_value = next((v for k, v in mapping['gender'].items() if k == gender), None)
|
30 |
native_country_value = next((v for k, v in mapping['native_country'].items() if k == native_country), None)
|
31 |
|
32 |
+
inputs = np.array([[age, workclass_value, education_value, education_num, marital_status_value, occupation_value, relationship_value, race_value, gender_value, capital_gain, capital_loss, hours_per_week, native_country_value]])
|
33 |
prediction = model.predict(inputs)
|
34 |
prediction_value = prediction[0][0] # Assuming the prediction is a scalar
|
35 |
result = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️"
|
|
|
49 |
gr.Slider(17, 90, label="Age"),
|
50 |
gr.Dropdown(dropdown_options['workclass'], label="Workclass"),
|
51 |
gr.Dropdown(dropdown_options['education'], label="Education"),
|
52 |
+
gr.Number(1, 16, label="Education Num [1 to 16]"),
|
53 |
gr.Dropdown(dropdown_options['marital_status'], label="Marital Status"),
|
54 |
gr.Dropdown(dropdown_options['occupation'], label="Occupation"),
|
55 |
gr.Dropdown(dropdown_options['relationship'], label="Relationship"),
|
56 |
gr.Dropdown(dropdown_options['race'], label="Race"),
|
57 |
gr.Dropdown(dropdown_options['gender'], label="Gender"),
|
58 |
+
gr.Number(0, 99999, label="Capital Gain [0 to 99999]"),
|
59 |
+
gr.Number(0, 4356, label="Capital Loss [0 to 4356]"),
|
60 |
+
gr.Number(1, 99, label="Hours per Week [1 to 99]"),
|
61 |
+
gr.Dropdown(dropdown_options['native_country'], label="Native Country")
|
62 |
],
|
63 |
outputs="text",
|
64 |
title="Salary Bracket Prediction",
|