AsthanM commited on
Commit
6fe9945
·
verified ·
1 Parent(s): 48bc56a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -23
app.py CHANGED
@@ -1,35 +1,42 @@
1
- import gradio as gr
2
  import joblib
3
- import pandas as pd
4
-
5
- # Load the trained model and label encoder
6
- model = joblib.load("employability_model_logreg.joblib")
7
- label_encoder = joblib.load("label_encoder_fixed.joblib")
8
-
9
- # Define feature names based on the dataset
10
- FEATURES = [
11
- "GENERAL APPEARANCE", "MANNER OF SPEAKING", "PHYSICAL CONDITION", "MENTAL ALERTNESS",
12
- "SELF-CONFIDENCE", "ABILITY TO PRESENT IDEAS", "COMMUNICATION SKILLS", "Student Performance Rating"
13
- ]
14
 
15
- def predict_employability(*inputs):
16
- # Convert inputs into DataFrame
17
- user_df = pd.DataFrame([inputs], columns=FEATURES)
 
 
 
 
18
 
19
  # Make prediction
20
- prediction = model.predict(user_df)[0]
21
- result = "✅ Employable" if prediction == 1 else "😞 Less Employable"
22
- return result
 
 
 
 
 
 
 
23
 
24
- # Create the Gradio interface
25
  iface = gr.Interface(
26
  fn=predict_employability,
27
- inputs=[gr.Slider(1, 5, step=1, label=feature) for feature in FEATURES],
28
- outputs="text",
 
 
 
 
 
 
29
  title="Employability Prediction",
30
- description="Rate yourself on the following attributes (1-5) to check if you're employable!"
31
  )
32
 
33
- # Launch the app
34
  if __name__ == "__main__":
35
  iface.launch()
 
 
1
  import joblib
2
+ import gradio as gr
3
+ import numpy as np
 
 
 
 
 
 
 
 
 
4
 
5
+ def predict_employability(manner_of_speaking, self_confidence, ability_to_present_ideas, communication_skills, mental_alertness):
6
+ # Load the updated model and label encoder
7
+ model = joblib.load("employability_model_selected.joblib")
8
+ label_encoder = joblib.load("label_encoder_fixed.joblib")
9
+
10
+ # Prepare the input data
11
+ input_data = np.array([[manner_of_speaking, self_confidence, ability_to_present_ideas, communication_skills, mental_alertness]])
12
 
13
  # Make prediction
14
+ prediction = model.predict(input_data)[0]
15
+
16
+ # Decode the prediction
17
+ result = label_encoder.inverse_transform([prediction])[0]
18
+
19
+ # Return the result with an emoji
20
+ if result == "Employable":
21
+ return f"✅ {result}"
22
+ else:
23
+ return f"😞 {result}"
24
 
25
+ # Define the Gradio interface
26
  iface = gr.Interface(
27
  fn=predict_employability,
28
+ inputs=[
29
+ gr.Slider(1, 5, step=1, label="Manner of Speaking"),
30
+ gr.Slider(1, 5, step=1, label="Self-Confidence"),
31
+ gr.Slider(1, 5, step=1, label="Ability to Present Ideas"),
32
+ gr.Slider(1, 5, step=1, label="Communication Skills"),
33
+ gr.Slider(1, 5, step=1, label="Mental Alertness")
34
+ ],
35
+ outputs=gr.Textbox(label="Prediction"),
36
  title="Employability Prediction",
37
+ description="Rate yourself on the given attributes (1-5) to check your employability status."
38
  )
39
 
40
+ # Run the Gradio app
41
  if __name__ == "__main__":
42
  iface.launch()