Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,26 +52,46 @@ def predict_performance(Location, College_Fee, College, GPA, Year, Course_Intere
|
|
52 |
# Convert to percentage
|
53 |
prediction_percentage = admission_probability * 100
|
54 |
|
55 |
-
#
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
except Exception as e:
|
69 |
-
return f"Error in prediction: {str(e)}"
|
70 |
|
71 |
-
#
|
72 |
iface = gr.Interface(
|
73 |
fn=predict_performance,
|
74 |
-
|
75 |
gr.Radio(["Kathmandu", "Bhaktapur", "Lalitpur", "Kritipur"], label="Location",info="What is your current location?"),
|
76 |
gr.Slider(minimum=1000000, maximum=1700000,step=100000,label="College Fee", info="What 's the the total bachelor fee for the course you want to enroll?"),
|
77 |
gr.Radio(["Trinity", "CCRC", "KMC", "SOS", "ISMT", "St. Xavier's", "Everest", "Prime"], label="College", info="What is the name of the last college you attended?"),
|
@@ -89,11 +109,14 @@ iface = gr.Interface(
|
|
89 |
gr.Radio(["Ram", "Gita", "Manish", "Shyam", "Raj", "Hari", "Rina", "Shree"], label="Presenter", info="who is the counser that help you while in counseling?"),
|
90 |
gr.Radio(["Yes", "No"], label="visited_with_parents", info="Did you visit the college with your parents?")
|
91 |
],
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
95 |
)
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
-
iface.launch(share=True)
|
99 |
-
|
|
|
52 |
# Convert to percentage
|
53 |
prediction_percentage = admission_probability * 100
|
54 |
|
55 |
+
# Create styled HTML output
|
56 |
+
# html_template = """
|
57 |
+
# <div style='text-align: center; padding: 20px;'>
|
58 |
+
# <div style='font-family: Arial, sans-serif; font-size: 24px; margin-bottom: 15px;'>
|
59 |
+
# Admission Probability: <span style='font-weight: bold;'>{:.1f}%</span>
|
60 |
+
# </div>
|
61 |
+
# <div style='{style}'>
|
62 |
+
# {message}
|
63 |
+
# </div>
|
64 |
+
# </div>
|
65 |
+
# """
|
66 |
+
# Create styled HTML output
|
67 |
+
html_template = """
|
68 |
+
<div style='text-align: center; padding: 20px;'>
|
69 |
+
<div style='{style}'>
|
70 |
+
{message}
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
"""
|
74 |
+
|
75 |
|
76 |
+
if prediction_percentage > 50:
|
77 |
+
style = "font-family: Arial, sans-serif; font-size: 32px; color: #28a745; font-weight: bold;"
|
78 |
+
message = "High chance of admission"
|
79 |
+
elif prediction_percentage < 50:
|
80 |
+
style = "font-family: Arial, sans-serif; font-size: 32px; color: #dc3545; font-weight: bold; text-transform: uppercase;"
|
81 |
+
message = "Lower chance of admission"
|
82 |
+
else: # exactly 50
|
83 |
+
style = "font-family: Arial, sans-serif; font-size: 32px; color: #ffc107; font-weight: bold;"
|
84 |
+
message = "Moderate chance of admission"
|
85 |
|
86 |
+
return html_template.format(prediction_percentage, style=style, message=message)
|
87 |
|
88 |
except Exception as e:
|
89 |
+
return f"<div style='color: red; font-family: Arial, sans-serif;'>Error in prediction: {str(e)}</div>"
|
90 |
|
91 |
+
# Update the Gradio interface
|
92 |
iface = gr.Interface(
|
93 |
fn=predict_performance,
|
94 |
+
inputs=[
|
95 |
gr.Radio(["Kathmandu", "Bhaktapur", "Lalitpur", "Kritipur"], label="Location",info="What is your current location?"),
|
96 |
gr.Slider(minimum=1000000, maximum=1700000,step=100000,label="College Fee", info="What 's the the total bachelor fee for the course you want to enroll?"),
|
97 |
gr.Radio(["Trinity", "CCRC", "KMC", "SOS", "ISMT", "St. Xavier's", "Everest", "Prime"], label="College", info="What is the name of the last college you attended?"),
|
|
|
109 |
gr.Radio(["Ram", "Gita", "Manish", "Shyam", "Raj", "Hari", "Rina", "Shree"], label="Presenter", info="who is the counser that help you while in counseling?"),
|
110 |
gr.Radio(["Yes", "No"], label="visited_with_parents", info="Did you visit the college with your parents?")
|
111 |
],
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
outputs=gr.HTML(), # Changed to HTML output
|
116 |
+
title="Student Admission Prediction",
|
117 |
+
description="Predict the probability of student admission",
|
118 |
+
css="body { font-family: Arial, sans-serif; }"
|
119 |
)
|
120 |
|
121 |
if __name__ == "__main__":
|
122 |
+
iface.launch(share=True)
|
|