Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
# Set up the app title and description
|
| 5 |
+
st.title("Personality Predictor")
|
| 6 |
+
st.write("Enter some text about yourself or someone else, and this app will predict personality traits based on the Big Five model.")
|
| 7 |
+
|
| 8 |
+
# Text input area
|
| 9 |
+
user_input = st.text_area("Write something here:", placeholder="E.g., I love meeting new people and trying new experiences.")
|
| 10 |
+
|
| 11 |
+
# Placeholder for trait predictions
|
| 12 |
+
traits = ["Extraversion", "Agreeableness", "Conscientiousness", "Neuroticism", "Openness"]
|
| 13 |
+
|
| 14 |
+
# Simulated predictions (replace with model predictions later)
|
| 15 |
+
def predict_personality(text):
|
| 16 |
+
# Placeholder logic: Assign random scores to traits
|
| 17 |
+
return {trait: round(random.uniform(0, 1), 2) for trait in traits}
|
| 18 |
+
|
| 19 |
+
# Button to predict personality
|
| 20 |
+
if st.button("Predict Personality"):
|
| 21 |
+
if user_input.strip():
|
| 22 |
+
# Call prediction function
|
| 23 |
+
predictions = predict_personality(user_input)
|
| 24 |
+
st.subheader("Predicted Personality Traits")
|
| 25 |
+
for trait, score in predictions.items():
|
| 26 |
+
st.write(f"**{trait}:** {score}")
|
| 27 |
+
else:
|
| 28 |
+
st.warning("Please enter some text to predict personality.")
|
| 29 |
+
|
| 30 |
+
# Footer
|
| 31 |
+
st.write("---")
|
| 32 |
+
st.write("This app uses NLP to simulate personality prediction. Replace the logic with a trained model for real predictions.")
|