crazy123 commited on
Commit
7d5b0ac
·
1 Parent(s): af93fff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ https://huggingface.co/spaces/meenon/AdmissionPrediction
3
+
4
+
5
+
6
+ import pickle
7
+ from sklearn.linear_model import LogisticRegression
8
+ import gradio as gr
9
+ import numpy as np
10
+
11
+ with open('logreg_model.pkl', "rb") as file:
12
+ loaded_model = pickle.load(file)
13
+
14
+ def predict_admission(gre_score, toefl_score, university_rating, sop, lor, cgpa, research, threshold=0.5):
15
+ # Convert 'Yes'/'No' to 1/0 for the 'Research' field
16
+ research = 1 if research == "Yes" else 0
17
+
18
+ # Create an input array from the provided values
19
+ input_data = np.array([[1, gre_score, toefl_score, university_rating, sop, lor, cgpa, research]]) # Added a 1 for the intercept
20
+
21
+ # Make a prediction
22
+ prediction_probability = loaded_model.predict(input_data)[0]
23
+ prediction = 'Admit' if prediction_probability >= threshold else 'No Admit'
24
+
25
+ # Custom formatting for output
26
+ prediction_color = "green" if prediction == 'Admit' else "red"
27
+ result = f"<div style='font-size: 24px; color: {prediction_color}; font-weight: bold; font-family: Arial Black;'>Admission Prediction: {prediction}</div>"
28
+ result += f"<br>Probability: {prediction_probability:.2f}"
29
+ result += f"<br>Threshold Used: {threshold}"
30
+
31
+ return result
32
+
33
+ # Define the Gradio interface
34
+ iface = gr.Interface(
35
+ fn=predict_admission,
36
+ inputs=[
37
+ gr.Number(label="GRE Score"), # Set maximum GRE score
38
+ gr.Number(label="TOEFL Score"),
39
+ gr.Slider(minimum=1, maximum=5, label="University Rating"),
40
+ gr.Slider(minimum=1, maximum=5, label="SOP"),
41
+ gr.Slider(minimum=1, maximum=5, label="LOR"),
42
+ gr.Number(label="CGPA"),
43
+ gr.Radio(choices=["Yes", "No"], label="Research", value="No"),
44
+ gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label="Threshold")
45
+ ],
46
+ outputs=gr.HTML(label="Prediction"),
47
+ allow_flagging="never"
48
+ )
49
+
50
+ iface.launch()