File size: 4,001 Bytes
5bbe02f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99267bc
 
 
 
 
 
5bbe02f
99267bc
 
 
 
 
 
5bbe02f
99267bc
 
 
 
 
 
5bbe02f
99267bc
 
 
 
 
 
5bbe02f
99267bc
 
 
 
 
 
5bbe02f
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Import necessary libraries
import gradio as gr
import joblib

# Load file
model = joblib.load("model")

# Personality predictor using KNN
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):
    #input from user
    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]]
    user_input_pred = model.predict(user_input)[0]

    output_msg = ""
    if user_input_pred == 0:
        output_msg = "Introverted and Reserved"

    elif user_input_pred == 1:
        output_msg = "Friendly and Outgoing"

    elif user_input_pred == 2:
        output_msg = "Emotionally Stable"

    elif user_input_pred == 3:
        output_msg = "Sympathetic and Caring"

    elif user_input_pred == 4:
        output_msg = "Organized and Disciplined"

    return output_msg

#Interface setup
Interface = gr.Interface(
    Personality_predict,
    inputs = [gr.components.Radio([1, 2, 3, 4, 5], label = "I dont talk a lot"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I feel comfortable around people"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I start conversations"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I have little to say"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I dont like to draw attention to myself"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I dont mind being the center of attention"),
              
              gr.components.Radio([1, 2, 3, 4, 5], label = "I get stressed out easily"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I am relaxed most of the time"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I seldom feel blue"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I get upset easily"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I change my mood a lot"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I have frequent mood swings"),

              gr.components.Radio([1, 2, 3, 4, 5], label = "I insult people"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I sympathize with others feelings"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I am not interested in other peoples problems"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I am not really interested in others"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I feel others emotions"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I make people feel at ease"),

              gr.components.Radio([1, 2, 3, 4, 5], label = "I am always prepared"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I leave my belongings around"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I make a mess of things"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I get chores done right away"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I often forget to put things back in their proper place"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I follow a schedule"),

              gr.components.Radio([1, 2, 3, 4, 5], label = "I have difficulty understanding abstract ideas"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I have a vivid imagination"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I am not interested in abstract ideas"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I have excellent ideas"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I do not have a good imagination"),
              gr.components.Radio([1, 2, 3, 4, 5], label = "I am quick to understand things")],

    outputs = ["text"],
    theme = 'blackpeach') 

Interface.launch()