tmdeptrai3012 commited on
Commit
baa7788
·
verified ·
1 Parent(s): 62cd188

Sync App files

Browse files
Files changed (3) hide show
  1. README.md +1 -3
  2. app.py +68 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -8,6 +8,4 @@ sdk_version: 5.35.0
8
  app_file: app.py
9
  pinned: false
10
  short_description: Decide whether you are introvert or extrovert
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_file: app.py
9
  pinned: false
10
  short_description: Decide whether you are introvert or extrovert
11
+ ---
 
 
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import skops.io as sio
3
+ import pandas as pd
4
+
5
+ pipe = sio.load("./Model/personality_pipeline.skops",trusted=["numpy.dtype","sklearn.compose._column_transformer._RemainderColsList"])
6
+ print("Succesfully loaded the model")
7
+
8
+ def predict_personality(Time_spent_Alone,Stage_fear,Social_event_attendance,Going_outside,Drained_after_socializing,Friends_circle_size,Post_frequency):
9
+ """Predict personality based on social features.
10
+
11
+ Args:
12
+ + Time_spent_Alone: Hours spent alone daily (0-11).
13
+ + Stage_fear: Presence of stage fright (Yes/No).
14
+ + Social_event_attendance: Frequency of social events (0-10).
15
+ + Going_outside: Frequency of going outside (0-7).
16
+ + Drained_after_socializing: Feeling drained after socializing (Yes/No).
17
+ + Friends_circle_size: Number of close friends (0-15).
18
+ + Post_frequency: Social media post frequency (0-10).
19
+
20
+ Returns:
21
+ str: Predicted drug label
22
+ """
23
+ features = [Time_spent_Alone,Stage_fear,Social_event_attendance,Going_outside,Drained_after_socializing,Friends_circle_size,Post_frequency]
24
+ columns = [
25
+ "Time_spent_Alone",
26
+ "Stage_fear",
27
+ "Social_event_attendance",
28
+ "Going_outside",
29
+ "Drained_after_socializing",
30
+ "Friends_circle_size",
31
+ "Post_frequency"
32
+ ]
33
+
34
+ df_input = pd.DataFrame([features], columns=columns)
35
+ predicted_personality = pipe.predict(df_input)[0]
36
+ return f"Predicted personality: {str(predicted_personality).upper()}"
37
+
38
+ inputs=[
39
+ gr.Slider(0,11,step=1,label="Time_spent_Alone",info="How many hours do you spend alone every day? (0-11)"),
40
+ gr.Radio(["Yes","No"],label="Stage_fear",info="Are you afraid of standing in front of crowds? (Yes/No)."),
41
+ gr.Slider(0,10,step=1,label="Social_event_attendance",info="How frequently do you participate in social events? (0-10)"),
42
+ gr.Slider(0,7,step=1,label="Going_outside",info="How many days per week do you go outside? (0-7)"),
43
+ gr.Radio(["Yes","No"],label="Drained_after_socializing",info="Do you feel exhausted after parties or interacting with many people? (Yes/No)."),
44
+ gr.Slider(0,15,step=1,label="Friends_circle_size",info="How many close friends do you have? (0-15)"),
45
+ gr.Slider(0,10,step=1,label="Post_frequency",info="How often do you post on social media? (0-10)"),
46
+ ]
47
+ outputs=[gr.Label(num_top_classes=5)]
48
+
49
+ examples=[
50
+ [4.0,"No",4.0,6.0,"No",13.0,5.0],
51
+ [9.0,"Yes",0.0,0.0,"Yes",0.0,3.0],
52
+ [9.0,"Yes",1.0,2.0,"Yes",5.0,2.0]
53
+ ]
54
+
55
+ title="Personality Classification"
56
+ description="Enter your social features to determine whether you are an Introvert or Extrovert"
57
+ article="This app is for my MLOps with CI/CD pipe line, pretty cool right?"
58
+
59
+ gr.Interface(
60
+ fn=predict_personality,
61
+ inputs=inputs,
62
+ outputs=outputs,
63
+ examples=examples,
64
+ title=title,
65
+ description=description,
66
+ article=article,
67
+ theme=gr.themes.Soft()
68
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ skops
2
+ gradio
3
+ pandas