tarunika-03 commited on
Commit
5bbe02f
1 Parent(s): 7d87ff2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary libraries
2
+ import gradio as gr
3
+ import joblib
4
+
5
+ # Load file
6
+ model = joblib.load("model")
7
+
8
+ # Personality predictor using KNN
9
+ def Personality_predict (EXT2, EXT3, EXT5, EXT6, EXT8, EXT9, EST1, EST2, EST4, EST6, EST7, EST8, AGR3, AGR4, AGR5, AGR7, AGR9, AGR10, CSN1, CSN2, CSN4, CSN5, CSN6, CSN9, OPN2, OPN3, OPN4, OPN5, OPN6, OPN7):
10
+ #input from user
11
+ user_input = [[EXT2, EXT3, EXT5, EXT6, EXT8, EXT9, EST1, EST2, EST4, EST6, EST7, EST8, AGR3, AGR4, AGR5, AGR7, AGR9, AGR10, CSN1, CSN2, CSN4, CSN5, CSN6, CSN9, OPN2, OPN3, OPN4, OPN5, OPN6, OPN7]]
12
+ user_input_pred = model.predict(user_input)[0]
13
+
14
+ output_msg = ""
15
+ if user_input_pred == 0:
16
+ output_msg = "Introverted and Reserved"
17
+
18
+ elif user_input_pred == 1:
19
+ output_msg = "Friendly and Outgoing"
20
+
21
+ elif user_input_pred == 2:
22
+ output_msg = "Emotionally Stable"
23
+
24
+ elif user_input_pred == 3:
25
+ output_msg = "Sympathetic and Caring"
26
+
27
+ elif user_input_pred == 4:
28
+ output_msg = "Organized and Disciplined"
29
+
30
+ return output_msg
31
+
32
+ #Interface setup
33
+ Interface = gr.Interface(
34
+ Personality_predict,
35
+ inputs = [gr.components.Radio(1, 5, label = "I dont talk a lot"),
36
+ gr.components.Radio(1, 5, label = "I feel comfortable around people"),
37
+ gr.components.Radio(1, 5, label = "I start conversations"),
38
+ gr.components.Radio(1, 5, label = "I have little to say"),
39
+ gr.components.Radio(1, 5, label = "I dont like to draw attention to myself"),
40
+ gr.components.Radio(1, 5, label = "I dont mind being the center of attention"),
41
+
42
+ gr.components.Radio(1, 5, label = "I get stressed out easily"),
43
+ gr.components.Radio(1, 5, label = "I am relaxed most of the time"),
44
+ gr.components.Radio(1, 5, label = "I seldom feel blue"),
45
+ gr.components.Radio(1, 5, label = "I get upset easily"),
46
+ gr.components.Radio(1, 5, label = "I change my mood a lot"),
47
+ gr.components.Radio(1, 5, label = "I have frequent mood swings"),
48
+
49
+ gr.components.Radio(1, 5, label = "I insult people"),
50
+ gr.components.Radio(1, 5, label = "I sympathize with others feelings"),
51
+ gr.components.Radio(1, 5, label = "I am not interested in other peoples problems"),
52
+ gr.components.Radio(1, 5, label = "I am not really interested in others"),
53
+ gr.components.Radio(1, 5, label = "I feel others emotions"),
54
+ gr.components.Radio(1, 5, label = "I make people feel at ease"),
55
+
56
+ gr.components.Radio(1, 5, label = "I am always prepared"),
57
+ gr.components.Radio(1, 5, label = "I leave my belongings around"),
58
+ gr.components.Radio(1, 5, label = "I make a mess of things"),
59
+ gr.components.Radio(1, 5, label = "I get chores done right away"),
60
+ gr.components.Radio(1, 5, label = "I often forget to put things back in their proper place"),
61
+ gr.components.Radio(1, 5, label = "I follow a schedule"),
62
+
63
+ gr.components.Radio(1, 5, label = "I have difficulty understanding abstract ideas"),
64
+ gr.components.Radio(1, 5, label = "I have a vivid imagination"),
65
+ gr.components.Radio(1, 5, label = "I am not interested in abstract ideas"),
66
+ gr.components.Radio(1, 5, label = "I have excellent ideas"),
67
+ gr.components.Radio(1, 5, label = "I do not have a good imagination"),
68
+ gr.components.Radio(1, 5, label = "I am quick to understand things")],
69
+
70
+ outputs = ["text"],
71
+ theme = 'blackpeach')
72
+
73
+ Interface.launch()
74
+