Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -1,15 +1,12 @@ 
     | 
|
| 1 | 
         
             
            import streamlit as st
         
     | 
| 2 | 
         
             
            from datasets import load_dataset
         
     | 
| 3 | 
         
            -
            from collections import Counter
         
     | 
| 4 | 
         | 
| 5 | 
         
            -
            # Load dataset  
     | 
| 6 | 
         
             
            @st.cache_resource
         
     | 
| 7 | 
         
            -
            def  
     | 
| 8 | 
         
            -
                 
     | 
| 9 | 
         
            -
                counts = Counter(example["label"] for example in dataset)
         
     | 
| 10 | 
         
            -
                return dataset, counts
         
     | 
| 11 | 
         | 
| 12 | 
         
            -
            mbti_data 
     | 
| 13 | 
         | 
| 14 | 
         
             
            # MBTI → Academic disciplines
         
     | 
| 15 | 
         
             
            mbti_to_disciplines = {
         
     | 
| 
         @@ -62,14 +59,6 @@ if user_input: 
     | 
|
| 62 | 
         | 
| 63 | 
         
             
                st.divider()
         
     | 
| 64 | 
         | 
| 65 | 
         
            -
                st.subheader("📊 How Common Is Your Type?")
         
     | 
| 66 | 
         
            -
                count = mbti_counts.get(user_input, 0)
         
     | 
| 67 | 
         
            -
                total = sum(mbti_counts.values())
         
     | 
| 68 | 
         
            -
                percentage = (count / total) * 100 if total > 0 else 0
         
     | 
| 69 | 
         
            -
                st.success(f"You're one of {count:,} people ({percentage:.2f}%) in the dataset with the {user_input} personality.")
         
     | 
| 70 | 
         
            -
             
     | 
| 71 | 
         
            -
                st.divider()
         
     | 
| 72 | 
         
            -
             
     | 
| 73 | 
         
             
                st.subheader("🎓 Recommended Academic Disciplines")
         
     | 
| 74 | 
         
             
                for field in mbti_to_disciplines[user_input]:
         
     | 
| 75 | 
         
             
                    st.markdown(f"- {field}")
         
     | 
| 
         | 
|
| 1 | 
         
             
            import streamlit as st
         
     | 
| 2 | 
         
             
            from datasets import load_dataset
         
     | 
| 
         | 
|
| 3 | 
         | 
| 4 | 
         
            +
            # Load dataset (not used for count anymore, but left in case needed later)
         
     | 
| 5 | 
         
             
            @st.cache_resource
         
     | 
| 6 | 
         
            +
            def load_mbti_data():
         
     | 
| 7 | 
         
            +
                return load_dataset("Shunian/kaggle-mbti-cleaned-augmented", split="train")
         
     | 
| 
         | 
|
| 
         | 
|
| 8 | 
         | 
| 9 | 
         
            +
            mbti_data = load_mbti_data()
         
     | 
| 10 | 
         | 
| 11 | 
         
             
            # MBTI → Academic disciplines
         
     | 
| 12 | 
         
             
            mbti_to_disciplines = {
         
     | 
| 
         | 
|
| 59 | 
         | 
| 60 | 
         
             
                st.divider()
         
     | 
| 61 | 
         | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 62 | 
         
             
                st.subheader("🎓 Recommended Academic Disciplines")
         
     | 
| 63 | 
         
             
                for field in mbti_to_disciplines[user_input]:
         
     | 
| 64 | 
         
             
                    st.markdown(f"- {field}")
         
     |