Tarun0203 commited on
Commit
8b701e7
·
verified ·
1 Parent(s): 2b12c38

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from sklearn.linear_model import Perceptron
4
+ import pandas as pd
5
+
6
+ file_path = "Student-Employability-Datasets (1).xlsx"
7
+ df = pd.read_excel(file_path, sheet_name='Data')
8
+
9
+ X = df.iloc[:, 1:-2].values
10
+ y = (df['CLASS'] == 'Employable').astype(int)
11
+
12
+ model = Perceptron()
13
+ model.fit(X, y)
14
+
15
+ def evaluate_employment(name, *ratings):
16
+ input_data = np.array(ratings).reshape(1, -1)
17
+ prediction = model.predict(input_data)[0]
18
+
19
+ if prediction == 1:
20
+ return f"{name}, Congrats! 🎉 You are employable."
21
+ else:
22
+ return f"{name}, Try to upgrade yourself! 📚"
23
+
24
+ def app():
25
+ with gr.Blocks() as demo:
26
+ name = gr.Textbox(label="Enter your name")
27
+ sliders = [gr.Slider(1, 5, step=1, label=col) for col in df.columns[1:-2]]
28
+ button = gr.Button("Get Yourself Evaluated")
29
+ output = gr.Textbox(label="Result")
30
+
31
+ button.click(evaluate_employment, inputs=[name] + sliders, outputs=output)
32
+
33
+ return demo
34
+
35
+ app().launch(share=True)