DeepActionPotential commited on
Commit
e9c150f
ยท
verified ยท
1 Parent(s): 1eee5fa

๐Ÿš€ Initial upload of my app

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ demo/demo.mp4 filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Eslam Tarek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,20 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: PersonaMind
3
- emoji: ๐Ÿš€
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: ML Model for Extrovert vs Introvert Classification
12
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
 
15
- # Welcome to Streamlit!
 
 
 
16
 
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
 
 
 
 
 
18
 
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
1
+ # PersonalityClassifier โ€” Introvert vs Extrovert Predictor
2
+
3
+ A lightweight Streamlit app that predicts whether a person is likely an Introvert or Extrovert from simple daily-behavior inputs.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+ - **[Demo](#demo)**
9
+ - **[Features](#features)**
10
+ - **[Installation / Setup](#installation--setup)**
11
+ - **[Usage](#usage)**
12
+ - **[Configuration / Options](#configuration--options)**
13
+ - **[Contributing](#contributing)**
14
+ - **[License](#license)**
15
+ - **[Acknowledgements / Credits](#acknowledgements--credits)**
16
+
17
+ ---
18
+
19
+ ## Demo
20
+ Real demo assets found in `./demo/`:
21
+
22
+ - Image: `./demo/demo.png`
23
+ - Video: `./demo/demo.mp4`
24
+
25
+ Example render:
26
+
27
+ ![App Screenshot](./demo/demo.png)
28
+
29
+ If your viewer supports video playback in Markdown, you can also preview the short clip:
30
+
31
+ ```text
32
+ ./demo/demo.mp4
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Features
38
+ - **Simple UI** built with `streamlit` for quick interaction.
39
+ - **Preprocessing utilities** in `utils.py` convert raw inputs to model-ready features.
40
+ - **Saved model loading** via `joblib` from `./models/model.pkl`.
41
+ - **Deterministic inference** using a binary classifier (Introvert vs Extrovert).
42
+
43
+ ---
44
+
45
+ ## Installation / Setup
46
+ Use a Python virtual environment for isolation.
47
+
48
+ ```bash
49
+ # Create a virtual environment
50
+ python -m venv .venv
51
+
52
+ # Activate it
53
+ # On Linux/Mac:
54
+ source .venv/bin/activate
55
+ # On Windows:
56
+ .venv\Scripts\activate
57
+
58
+ # Install dependencies
59
+ pip install -r requirements.txt
60
+ ```
61
+
62
  ---
63
+
64
+ ## Usage
65
+ Run the Streamlit app locally:
66
+
67
+ ```bash
68
+ streamlit run app.py
69
+ ```
70
+
71
+ App entrypoint: `app.py`
72
+ - Loads the model using `utils.load_model("./models/model.pkl")`.
73
+ - Renders inputs and predictions using helpers in `ui.py`.
74
+
75
+ Expected project structure:
76
+ ```
77
+ PersonalityClassifier/
78
+ โ”œโ”€ app.py
79
+ โ”œโ”€ ui.py
80
+ โ”œโ”€ utils.py
81
+ โ”œโ”€ models/
82
+ โ”‚ โ””โ”€ model.pkl
83
+ โ””โ”€ demo/
84
+ โ”œโ”€ demo.png
85
+ โ””โ”€ demo.mp4
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Configuration / Options
91
+ - **Model path**: `./models/model.pkl` (default in `app.py`). Replace the file if you want another trained model. Ensure the environment includes the libraries used to train/serialize it (e.g., `scikit-learn`).
92
+ - **Caching**: `utils.load_model` uses `@st.cache_resource` to cache the loaded model across reruns.
93
+
94
  ---
95
 
96
+ ## Contributing
97
+ Contributions are welcome! Please:
98
+ - **Open an issue** to discuss proposed changes.
99
+ - **Create a PR** with a clear description, small focused commits, and screenshots for UI changes.
100
 
101
+ ---
102
+
103
+ ## License
104
+ This project is licensed under the **MIT License**. See the [`LICENSE`](./LICENSE) file for details.
105
+
106
+ ---
107
 
108
+ ## Acknowledgements / Credits
109
+ - **Streamlit** for rapid web UI development.
110
+ - **scikit-learn** and **joblib** for model training/serialization workflows.
__pycache__/ui.cpython-311.pyc ADDED
Binary file (2.66 kB). View file
 
__pycache__/utils.cpython-311.pyc ADDED
Binary file (1.65 kB). View file
 
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ from utils import load_model, preprocess_input, predict_personality
4
+ from ui import render_header, render_input_form, render_prediction
5
+
6
+ # Set page config with light theme
7
+ st.set_page_config(page_title="Personality Predictor", layout="centered", initial_sidebar_state="auto")
8
+
9
+ # Render the app header
10
+ render_header()
11
+
12
+ # Load model
13
+ model = load_model("./models/model.pkl")
14
+
15
+ # Render input form and collect user inputs
16
+ user_input = render_input_form()
17
+
18
+ # When user submits, preprocess and predict
19
+ if user_input is not None:
20
+ X = preprocess_input(user_input)
21
+ prediction, prob = predict_personality(model, X)
22
+ render_prediction(prediction, prob)
demo/demo.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ceef246a52555220e5d9211728973144715240e44479e965386dd79a2d43f8a0
3
+ size 769583
demo/demo.png ADDED
extrovert-introvert-personality-prediction-f1-93.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
models/model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0a717ef48ea4fe42fa96b6bff5d54a402c8749db7fe02b35fa89d8d96111747
3
+ size 35163
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
- altair
2
- pandas
3
- streamlit
 
 
1
+ streamlit==1.38.0
2
+ pandas==2.2.2
3
+ joblib==1.4.2
4
+ scikit-learn==1.4.2
ui.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def render_header():
4
+ st.title("๐Ÿ”ฎ Personality Predictor")
5
+ st.write("Enter your daily behavior to predict whether you are an Introvert or Extrovert.")
6
+
7
+
8
+ def render_input_form():
9
+ with st.form(key='input_form'):
10
+ time_alone = st.slider("Hours spent alone daily", 0, 11, 4)
11
+ stage_fear = st.selectbox("Stage fear?", ["Yes", "No"])
12
+ social_events = st.slider("Social event attendance (0-10)", 0, 10, 5)
13
+ going_out = st.slider("Days go outside per week", 0, 7, 3)
14
+ drained = st.selectbox("Drained after socializing?", ["Yes", "No"])
15
+ friends = st.slider("Number of close friends", 0, 15, 5)
16
+ posts = st.slider("Social media posts per day", 0, 10, 3)
17
+ submit = st.form_submit_button("Predict")
18
+ if submit:
19
+ return {
20
+ 'Time_spent_Alone': time_alone,
21
+ 'Stage_fear': stage_fear,
22
+ 'Social_event_attendance': social_events,
23
+ 'Going_outside': going_out,
24
+ 'Drained_after_socializing': drained,
25
+ 'Friends_circle_size': friends,
26
+ 'Post_frequency': posts
27
+ }
28
+ return None
29
+
30
+
31
+ def render_prediction(label, probability):
32
+ st.subheader("Prediction Result")
33
+ st.write(f"**Personality**: {label}")
34
+ # st.write(f"**Confidence**: {probability * 100:.1f}%")
35
+ if label == "Introvert":
36
+ st.info("You are likely an Introvert. ๐ŸŒฑ")
37
+ else:
38
+ st.success("You are likely an Extrovert. ๐ŸŽ‰")
utils.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # utils.py
2
+ import joblib
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+ @st.cache_resource
7
+ def load_model(path: str):
8
+ return joblib.load(path)
9
+
10
+ def preprocess_input(data: dict) -> pd.DataFrame:
11
+ # Build a single-row DF
12
+ df = pd.DataFrame([data])
13
+
14
+ # Map Yes/No to 1/0
15
+ df['Stage_fear'] = df['Stage_fear'].map({'Yes': 1, 'No': 0})
16
+ df['Drained_after_socializing'] = df['Drained_after_socializing'].map({'Yes': 1, 'No': 0})
17
+
18
+
19
+ feature_order = [
20
+ 'Time_spent_Alone',
21
+ 'Stage_fear',
22
+ 'Social_event_attendance',
23
+ 'Going_outside',
24
+ 'Friends_circle_size',
25
+ 'Post_frequency'
26
+ ]
27
+
28
+ # Reorder and return
29
+ return df[feature_order]
30
+
31
+ def predict_personality(model, X: pd.DataFrame):
32
+ # Make sure to pass a numpy array if your model expects that:
33
+ arr = X.values
34
+ prob = model.predict_proba(arr)[:, 1][0]
35
+ label = "Introvert" if prob > 0.5 else "Extrovert"
36
+ return label, prob