Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,22 @@ class ComprehensiveSocialMediaAnalyzer:
|
|
| 40 |
"""Load and prepare the dataset"""
|
| 41 |
try:
|
| 42 |
# Load the dataset
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# Create binary features for categorical variables
|
| 46 |
self.df['Is_Female'] = (self.df['Gender'] == 'Female').astype(int)
|
|
@@ -569,7 +584,6 @@ with gr.Blocks(title="Social Media Addiction Analysis - Comprehensive", theme=gr
|
|
| 569 |
### Data Source
|
| 570 |
Analysis based on comprehensive student social media usage survey data.
|
| 571 |
""")
|
| 572 |
-
|
| 573 |
# Launch the app
|
| 574 |
if __name__ == "__main__":
|
| 575 |
demo.launch(share=True)
|
|
|
|
| 40 |
"""Load and prepare the dataset"""
|
| 41 |
try:
|
| 42 |
# Load the dataset
|
| 43 |
+
import os
|
| 44 |
+
# Try multiple possible paths
|
| 45 |
+
possible_paths = [
|
| 46 |
+
"data/Students Social Media Addiction.csv",
|
| 47 |
+
"./data/Students Social Media Addiction.csv",
|
| 48 |
+
"../data/Students Social Media Addiction.csv",
|
| 49 |
+
os.path.join(os.path.dirname(__file__), "data", "Students Social Media Addiction.csv")
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
for path in possible_paths:
|
| 53 |
+
if os.path.exists(path):
|
| 54 |
+
self.df = pd.read_csv(path)
|
| 55 |
+
print(f"✅ Data loaded from: {path}")
|
| 56 |
+
break
|
| 57 |
+
else:
|
| 58 |
+
raise FileNotFoundError("Could not find the data file in any expected location")
|
| 59 |
|
| 60 |
# Create binary features for categorical variables
|
| 61 |
self.df['Is_Female'] = (self.df['Gender'] == 'Female').astype(int)
|
|
|
|
| 584 |
### Data Source
|
| 585 |
Analysis based on comprehensive student social media usage survey data.
|
| 586 |
""")
|
|
|
|
| 587 |
# Launch the app
|
| 588 |
if __name__ == "__main__":
|
| 589 |
demo.launch(share=True)
|