pratik1000 commited on
Commit
4e5f07a
Β·
verified Β·
1 Parent(s): 4ecc980

Upload 6 files

Browse files
per/README.md ADDED
Binary file (2.59 kB). View file
 
per/app.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pickle
4
+ import pandas as pd
5
+
6
+ # Load model
7
+ with open('model.pkl', 'rb') as file:
8
+ model = pickle.load(file)
9
+
10
+
11
+
12
+ # Set page config with background
13
+ st.set_page_config(page_title="Personality Predictor", layout="centered")
14
+ # Custom CSS for background image
15
+ st.markdown("""
16
+ <style>
17
+ .stApp {
18
+ background-image: url("");
19
+ background-size: cover;
20
+ background-repeat: no-repeat;
21
+ background-attachment: fixed;
22
+ }
23
+ </style>
24
+ """, unsafe_allow_html=True)
25
+
26
+ st.title("🧠 Personality Prediction App")
27
+ st.markdown("πŸš€ This app uses a Machine Learning model to analyze your social behavior and predict whether you're an Extrovert or an Introvert.")
28
+
29
+ # --- Input Section ---
30
+ col1, col2 = st.columns(2)
31
+
32
+ with col1:
33
+ Time_spent_Alone= st.slider("πŸ•’ Time Spent Alone (1-24) in Hours", 0, 24, 5)
34
+ Social_event_attendance= st.slider("πŸŽ‰ How Many Social Event You Attended Recently (1-15)", 0, 15, 5)
35
+ Friends_circle_size = st.slider("πŸ‘₯ Friends Circle Size", 0, 5, 50)
36
+ Post_frequency = st.slider("πŸ“± How Much Post You Upload On Social Media Recently", 0, 20, 5)
37
+
38
+ with col2:
39
+ Going_outside = st.slider("🚢 Going Outside (1-10)", 0, 10, 5)
40
+ Stage_fear = st.selectbox("🎀 Do you have stage fear?", ["Yes", "No"])
41
+ Drained_after_socializing = st.selectbox("😩 Do social events make you feel exhausted?", ["Yes", "No"])
42
+
43
+ # Encode categorical inputs
44
+ stage_fear_encoded = 1 if Stage_fear == "Yes" else 0
45
+ drained_encoded = 1 if Drained_after_socializing == "Yes" else 0
46
+ # --- Predict ---
47
+
48
+ # Extrovert Case
49
+ if st.button("πŸ” Predict Personality"):
50
+ # Prepare input DataFrame
51
+ data = pd.DataFrame([{
52
+ "Time_spent_Alone": Time_spent_Alone,
53
+ "Stage_fear": stage_fear_encoded,
54
+ "Social_event_attendance": Social_event_attendance,
55
+ "Going_outside": Going_outside,
56
+ "Drained_after_socializing": drained_encoded,
57
+ "Friends_circle_size": Friends_circle_size,
58
+ "Post_frequency": Post_frequency
59
+ }])
60
+
61
+ # Make prediction
62
+ prediction = model.predict(data)
63
+
64
+ # πŸŽ‰ Extrovert Case
65
+ if prediction[0] == 0 or prediction[0] == "Extrovert":
66
+ # st.success("βœ… You are likely an **Extrovert** πŸŽ‰")
67
+ st.markdown("""
68
+ <div style='
69
+ background-color: #d4edda;
70
+ color: #155724;
71
+ padding: 20px;
72
+ border-radius: 10px;
73
+ font-size: 32px;
74
+ font-weight: bold;
75
+ text-align: center;
76
+ line-height: 1.6;
77
+ '>
78
+ βœ… You are likely an <strong>Extrovert</strong> πŸŽ‰
79
+ </div>
80
+ """, unsafe_allow_html=True)
81
+
82
+ st.balloons()
83
+
84
+ st.markdown("""
85
+ <div style='text-align: center;'>
86
+ <style>
87
+ .float-up {
88
+ animation: floatUp 2s ease-in-out forwards;
89
+ font-size: 40px;
90
+ position: relative;
91
+ }
92
+
93
+ @keyframes floatUp {
94
+ 0% { bottom: -50px; opacity: 0; }
95
+ 50% { bottom: 0px; opacity: 1; }
96
+ 100% { bottom: 50px; opacity: 0; }
97
+ }
98
+ </style>
99
+ <div class="float-up">πŸŽ‰πŸ˜Žβœ¨πŸŽŠπŸ•Ί</div>
100
+ </div>
101
+ """, unsafe_allow_html=True)
102
+
103
+ # 😌 Introvert Case
104
+ else:
105
+ # st.warning("πŸ”• You are likely an **Introvert** 😌")
106
+ st.markdown("""
107
+ <div style='
108
+ background-color: #f8f9fa;
109
+ color: #343a40;
110
+ padding: 20px;
111
+ border-radius: 10px;
112
+ font-size: 32px;
113
+ font-weight: bold;
114
+ text-align: center;
115
+ line-height: 1.6;
116
+ '>
117
+ πŸ”• You are likely an <strong>Introvert</strong> 😌
118
+ </div>
119
+ """, unsafe_allow_html=True)
120
+
121
+ st.snow()
122
+
123
+ st.markdown("""
124
+ <div style='text-align: center;'>
125
+ <style>
126
+ .float-up-slow {
127
+ animation: floatSlow 3s ease-in-out forwards;
128
+ font-size: 40px;
129
+ position: relative;
130
+ }
131
+
132
+ @keyframes floatSlow {
133
+ 0% { bottom: -30px; opacity: 0; }
134
+ 50% { bottom: 0px; opacity: 1; }
135
+ 100% { bottom: 30px; opacity: 0; }
136
+ }
137
+ </style>
138
+ <div class="float-up-slow">πŸ’­πŸ§˜β€β™‚οΈπŸ˜Άβ€πŸŒ«οΈπŸŒ™</div>
139
+ </div>
140
+ """, unsafe_allow_html=True)
per/model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8f153f2d71132b919b726dae6eb5a0f3deb13d9c873618cba8fb64d1761bf07
3
+ size 550113
per/personality_dataset.csv ADDED
The diff for this file is too large to render. See raw diff
 
per/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit==1.35.0
2
+ scikit-learn==1.3.2
3
+ pandas==2.2.2
4
+
per/train.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from sklearn.preprocessing import LabelEncoder
3
+ from sklearn.model_selection import train_test_split
4
+ from sklearn.neighbors import KNeighborsClassifier
5
+ import pickle
6
+
7
+ #loading the dataset
8
+ data=pd.read_csv("personality_dataset.csv")
9
+ data=pd.DataFrame(data)
10
+
11
+ #Encoding the data
12
+
13
+ Encoder=LabelEncoder()
14
+ data['Stage_fear']=Encoder.fit_transform(data['Stage_fear'])
15
+ data['Drained_after_socializing']=Encoder.fit_transform(data['Drained_after_socializing'])
16
+ data['Personality']=Encoder.fit_transform(data['Personality'])
17
+
18
+
19
+ #spliting the data into Two parts
20
+ x=data.iloc[:,:-1]
21
+ y=data['Personality']
22
+
23
+ #spliting the data into traning and testing
24
+
25
+ x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=42)
26
+
27
+ #traning model
28
+ model=KNeighborsClassifier(n_neighbors=20,metric='euclidean')
29
+
30
+ model.fit(x_train,y_train)
31
+
32
+ with open('model.pkl', 'wb') as file:
33
+ pickle.dump(model, file)