Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,42 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import joblib
|
| 3 |
-
import
|
| 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(
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Make prediction
|
| 20 |
-
prediction = model.predict(
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
#
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=predict_employability,
|
| 27 |
-
inputs=[
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
title="Employability Prediction",
|
| 30 |
-
description="Rate yourself on the
|
| 31 |
)
|
| 32 |
|
| 33 |
-
#
|
| 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()
|