Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -195,25 +195,25 @@ class SocialMediaAnalyzer:
|
|
| 195 |
angle = 180 - (predicted_score - 1) * 20 # 20 degrees per unit (180/9)
|
| 196 |
|
| 197 |
# Create the gauge
|
| 198 |
-
# Background circle (full range)
|
| 199 |
-
theta = np.linspace(
|
| 200 |
ax.plot(theta, [1]*100, 'k-', linewidth=3)
|
| 201 |
|
| 202 |
-
# Color zones
|
| 203 |
# Low addiction (1-3): Green
|
| 204 |
-
low_angle = np.linspace(
|
| 205 |
ax.fill_between(low_angle, 0, 1, alpha=0.3, color='green', label='Low (1-3)')
|
| 206 |
|
| 207 |
# Moderate addiction (3-7): Orange
|
| 208 |
-
mod_angle = np.linspace(2*20*np.pi/180, 6*20*np.pi/180, 50)
|
| 209 |
ax.fill_between(mod_angle, 0, 1, alpha=0.3, color='orange', label='Moderate (3-7)')
|
| 210 |
|
| 211 |
# High addiction (7-10): Red
|
| 212 |
-
high_angle = np.linspace(6*20*np.pi/180, np.pi, 50)
|
| 213 |
ax.fill_between(high_angle, 0, 1, alpha=0.3, color='red', label='High (7-10)')
|
| 214 |
|
| 215 |
-
# Add the needle
|
| 216 |
-
needle_angle = angle * np.pi / 180
|
| 217 |
ax.plot([needle_angle, needle_angle], [0, 1.2], 'k-', linewidth=4, label=f'Your Score: {predicted_score:.1f}')
|
| 218 |
|
| 219 |
# Add a circle at the needle tip
|
|
@@ -228,10 +228,10 @@ class SocialMediaAnalyzer:
|
|
| 228 |
ax.set_yticks([])
|
| 229 |
ax.set_ylim(0, 1.3)
|
| 230 |
|
| 231 |
-
# Add text labels
|
| 232 |
-
ax.text(
|
| 233 |
-
ax.text(
|
| 234 |
-
ax.text(np.pi, 1.4, 'High\n(7-10)', ha='center', va='center', fontsize=10, fontweight='bold')
|
| 235 |
|
| 236 |
# Add confidence if available
|
| 237 |
if 'confidence' in result:
|
|
|
|
| 195 |
angle = 180 - (predicted_score - 1) * 20 # 20 degrees per unit (180/9)
|
| 196 |
|
| 197 |
# Create the gauge
|
| 198 |
+
# Background circle (full range, rotated by -90°)
|
| 199 |
+
theta = np.linspace(-np.pi/2, np.pi/2, 100)
|
| 200 |
ax.plot(theta, [1]*100, 'k-', linewidth=3)
|
| 201 |
|
| 202 |
+
# Color zones (rotate by -90° to make 0° at left instead of top)
|
| 203 |
# Low addiction (1-3): Green
|
| 204 |
+
low_angle = np.linspace(-np.pi/2, -np.pi/2 + 2*20*np.pi/180, 50)
|
| 205 |
ax.fill_between(low_angle, 0, 1, alpha=0.3, color='green', label='Low (1-3)')
|
| 206 |
|
| 207 |
# Moderate addiction (3-7): Orange
|
| 208 |
+
mod_angle = np.linspace(-np.pi/2 + 2*20*np.pi/180, -np.pi/2 + 6*20*np.pi/180, 50)
|
| 209 |
ax.fill_between(mod_angle, 0, 1, alpha=0.3, color='orange', label='Moderate (3-7)')
|
| 210 |
|
| 211 |
# High addiction (7-10): Red
|
| 212 |
+
high_angle = np.linspace(-np.pi/2 + 6*20*np.pi/180, np.pi/2, 50)
|
| 213 |
ax.fill_between(high_angle, 0, 1, alpha=0.3, color='red', label='High (7-10)')
|
| 214 |
|
| 215 |
+
# Add the needle (rotate by -90° to make 0° at left instead of top)
|
| 216 |
+
needle_angle = (angle - 90) * np.pi / 180
|
| 217 |
ax.plot([needle_angle, needle_angle], [0, 1.2], 'k-', linewidth=4, label=f'Your Score: {predicted_score:.1f}')
|
| 218 |
|
| 219 |
# Add a circle at the needle tip
|
|
|
|
| 228 |
ax.set_yticks([])
|
| 229 |
ax.set_ylim(0, 1.3)
|
| 230 |
|
| 231 |
+
# Add text labels (rotated by -90° to match gauge orientation)
|
| 232 |
+
ax.text(-np.pi/2, 1.4, 'Low\n(1-3)', ha='center', va='center', fontsize=10, fontweight='bold')
|
| 233 |
+
ax.text(0, 1.4, 'Moderate\n(3-7)', ha='center', va='center', fontsize=10, fontweight='bold')
|
| 234 |
+
ax.text(np.pi/2, 1.4, 'High\n(7-10)', ha='center', va='center', fontsize=10, fontweight='bold')
|
| 235 |
|
| 236 |
# Add confidence if available
|
| 237 |
if 'confidence' in result:
|