Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,19 +104,23 @@ if st.button("Generate DataFrame"):
|
|
104 |
plt.ylabel('Data Points')
|
105 |
st.pyplot(plt)
|
106 |
|
107 |
-
|
108 |
-
df_normalized = (df_emotions.iloc[:, :7] - df_emotions.iloc[:, :7].min()) / (df_emotions.iloc[:, :7].max() - df_emotions.iloc[:, :7].min())
|
109 |
-
|
110 |
-
# Plotting the parallel coordinates plot
|
111 |
-
plt.figure(figsize=(12, 6))
|
112 |
-
parallel_coordinates(df_normalized, class_column=None, colormap=plt.get_cmap("Set2"))
|
113 |
-
plt.title('Parallel Coordinates Plot for Emotions')
|
114 |
-
plt.xlabel('Emotion Categories')
|
115 |
-
plt.ylabel('Normalized Scores')
|
116 |
-
st.pyplot(plt)
|
117 |
|
118 |
# Optional: Save the DataFrame to a CSV file
|
119 |
df_emotions.to_csv('emotion_scores.csv', index=False)
|
120 |
st.success('DataFrame generated and saved as emotion_scores.csv')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
else:
|
122 |
st.error("No results to generate DataFrame. Please predict emotions first.")
|
|
|
104 |
plt.ylabel('Data Points')
|
105 |
st.pyplot(plt)
|
106 |
|
107 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
# Optional: Save the DataFrame to a CSV file
|
110 |
df_emotions.to_csv('emotion_scores.csv', index=False)
|
111 |
st.success('DataFrame generated and saved as emotion_scores.csv')
|
112 |
+
|
113 |
+
with open('emotion_scores.csv', 'r') as f:
|
114 |
+
csv_file = f.read()
|
115 |
+
|
116 |
+
st.download_button(
|
117 |
+
label='Download Emotion Scores as CSV',
|
118 |
+
data=csv_file,
|
119 |
+
file_name='emotion_scores.csv',
|
120 |
+
mime='text/csv',
|
121 |
+
)
|
122 |
+
|
123 |
+
st.success('DataFrame generated and available for download.')
|
124 |
+
|
125 |
else:
|
126 |
st.error("No results to generate DataFrame. Please predict emotions first.")
|