MoinulwithAI commited on
Commit
abad883
·
verified ·
1 Parent(s): 48d79b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -18,11 +18,28 @@ trait_prefixes = {
18
  'Openness': 'OPN'
19
  }
20
 
21
- # Create full feature names with full form labels
22
- feature_labels = []
23
- for trait in trait_prefixes:
24
- for i in range(10):
25
- feature_labels.append(f"{trait} Q{i+1}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  # Inference function
28
  def predict_personality(*inputs):
@@ -32,10 +49,7 @@ def predict_personality(*inputs):
32
  personality = encoder.inverse_transform(pred)[0]
33
  return f"Predicted Personality: **{personality}**"
34
 
35
- # Gradio UI: 50 sliders with full trait names
36
- inputs = [gr.Slider(1.0, 5.0, value=3.0, label=label) for label in feature_labels]
37
- output = gr.Textbox(label="Prediction")
38
-
39
  demo = gr.Interface(
40
  fn=predict_personality,
41
  inputs=inputs,
 
18
  'Openness': 'OPN'
19
  }
20
 
21
+ # Example IPIP-FFM questionnaire questions (replace with actual questions)
22
+ questions = [
23
+ "I am the life of the party.", "I feel comfortable around people.", "I often feel blue.", "I am easily disturbed.",
24
+ "I enjoy trying new things.", "I am talkative.", "I don't mind being the center of attention.", "I often get upset.",
25
+ "I am interested in abstract ideas.", "I am full of energy.", "I would rather sit at home than go out.",
26
+ "I don't like to draw attention to myself.", "I am sometimes easily angered.", "I have frequent mood swings.",
27
+ "I like to travel to new places.", "I like to meet new people.", "I enjoy having a wide variety of friends.",
28
+ "I am good at handling stress.", "I often feel like I’m not in control of my emotions.", "I prefer variety to routine.",
29
+ "I am a very anxious person.", "I prefer to stick to one activity at a time.", "I enjoy being active in social settings.",
30
+ "I don’t like to take risks.", "I get along with most people.", "I get bored easily.", "I tend to be impulsive.",
31
+ "I like being organized.", "I feel uncomfortable around strangers.", "I avoid conflict with others.", "I have a lot of energy.",
32
+ "I find it difficult to express my emotions.", "I often feel lonely.", "I like to keep my thoughts and feelings to myself.",
33
+ "I find it difficult to relax.", "I am always prepared.", "I sometimes feel down.", "I find it difficult to focus on one task.",
34
+ "I enjoy the company of others.", "I like to talk about my feelings.", "I can’t stand being interrupted.",
35
+ "I often forget to do things.", "I am good at understanding other people’s feelings.", "I enjoy taking on challenges.",
36
+ "I often feel overwhelmed.", "I like to take my time making decisions.", "I enjoy being in charge.", "I am easily distracted.",
37
+ "I get along well with others.", "I enjoy being the center of attention."
38
+ ]
39
+
40
+ # Create sliders with questions
41
+ inputs = [gr.Slider(1.0, 5.0, value=3.0, label=q) for q in questions]
42
+ output = gr.Textbox(label="Prediction")
43
 
44
  # Inference function
45
  def predict_personality(*inputs):
 
49
  personality = encoder.inverse_transform(pred)[0]
50
  return f"Predicted Personality: **{personality}**"
51
 
52
+ # Gradio UI with 50 sliders and full question labels
 
 
 
53
  demo = gr.Interface(
54
  fn=predict_personality,
55
  inputs=inputs,