| import streamlit as st |
| import pandas as pd |
| import numpy as np |
| import joblib |
|
|
| |
| try: |
| model = joblib.load('src/introvert_model.joblib') |
| except FileNotFoundError: |
| st.error("Model file not found.") |
| st.stop() |
|
|
| |
| st.set_page_config(page_title="Personality Predictor", page_icon="🧠") |
|
|
| st.title("🧠 Introvert vs. Extrovert Predictor") |
| st.write("This application predicts whether you are an **Introvert** or an **Extrovert** based on your social habits and preferences.") |
|
|
| |
| with st.sidebar: |
| st.header("Please Enter Your Details") |
| time_spent_alone = st.slider("Time Spent Alone (Hours/Day)", 0.0, 10.0, 3.5) |
| social_event_attendance = st.slider("Social Event Attendance (Frequency 0-10)", 0, 10, 5) |
| going_outside = st.slider("Frequency of Going Out (0-10)", 0, 10, 5) |
| friends_circle_size = st.number_input("Friends Circle Size", min_value=0, max_value=20, value=5) |
| post_frequency = st.slider("Social Media Post Frequency (0-10)", 0, 10, 2) |
| stage_fear_input = st.radio("Do you have Stage Fear?", ["Yes", "No"]) |
| drained_input = st.radio("Do you feel drained after socializing?", ["Yes", "No"]) |
|
|
| |
| stage_fear = 1 if stage_fear_input == "Yes" else 0 |
| drained = 1 if drained_input == "Yes" else 0 |
| social_to_alone_ratio = social_event_attendance / (time_spent_alone + 1) |
| social_volume = friends_circle_size * going_outside |
|
|
| |
| input_data = pd.DataFrame({ |
| 'Time_spent_Alone': [time_spent_alone], |
| 'Stage_fear': [stage_fear], |
| 'Social_event_attendance': [social_event_attendance], |
| 'Going_outside': [going_outside], |
| 'Drained_after_socializing': [drained], |
| 'Friends_circle_size': [friends_circle_size], |
| 'Post_frequency': [post_frequency], |
| 'Social_to_Alone_Ratio': [social_to_alone_ratio], |
| 'Social_Volume': [social_volume]}) |
|
|
| |
| st.subheader("Prediction Result") |
| if st.button("Analyze Personality"): |
| prediction = model.predict(input_data)[0] |
| if prediction == 1: |
| st.success("Result: **INTROVERT**") |
| st.info("You likely prefer staying in your own space and recharging your energy through solitude.") |
| else: |
| st.info("Result: **EXTROVERT**") |
| st.success("You likely gain energy from social environments and enjoy engaging with the outside world.") |