Spaces:
Runtime error
Runtime error
Antigravity Deploy Agent
Deploy Suicide Risk Detection web application to Hugging Face Spaces
0be18fb | import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| # Load dataset | |
| df = pd.read_csv("data/processed/text_all_clean.csv") | |
| # Basic info | |
| print("🔹 Dataset Shape:", df.shape) | |
| print("\n🔹 Columns:", df.columns.tolist()) | |
| # Check missing values | |
| print("\n🔹 Missing Values:\n", df.isnull().sum()) | |
| # Label distribution | |
| print("\n🔹 Label Distribution:\n", df['label'].value_counts()) | |
| # Percentage distribution | |
| label_percent = df['label'].value_counts(normalize=True) * 100 | |
| print("\n🔹 Label Percentage:\n", label_percent) | |
| # Plot distribution | |
| plt.figure() | |
| sns.countplot(x='label', data=df) | |
| plt.title("Label Distribution") | |
| plt.xlabel("Class (0 = Non-suicidal, 1 = Suicidal)") | |
| plt.ylabel("Count") | |
| plt.show() | |
| # Optional: language distribution (if useful) | |
| if 'lang' in df.columns: | |
| print("\n🔹 Language Distribution:\n", df['lang'].value_counts()) | |
| # Check text length stats | |
| df['text_length'] = df['text'].astype(str).apply(len) | |
| print("\n🔹 Text Length Stats:\n", df['text_length'].describe()) | |
| plt.figure() | |
| sns.histplot(df['text_length'], bins=50) | |
| plt.title("Text Length Distribution") | |
| plt.show() |