Hemg commited on
Commit
0575917
·
verified ·
1 Parent(s): a5b46f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -18
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
- # Format the output
56
- confidence_level = ""
57
- if prediction_percentage > 50:
58
- confidence_level = "High chance of admission"
59
- elif prediction_percentage == 50:
60
- confidence_level = "Moderate chance of admission"
61
- else:
62
- confidence_level = "Lower chance of admission"
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- return confidence_level
 
 
 
 
 
 
 
 
65
 
66
- #return f"Admission Probability: {prediction_percentage:.1f}%\n{confidence_level}"
67
 
68
  except Exception as e:
69
- return f"Error in prediction: {str(e)}"
70
 
71
- # Create Gradio interface
72
  iface = gr.Interface(
73
  fn=predict_performance,
74
- inputs=[
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
- outputs="text",
93
- title="Student Admission Prediction App",
94
- description="Predict the probability of student admission for Bachelor Study"
 
 
 
 
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)