Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,6 +53,11 @@ def print_topics(lda, vectorizer, num_words=10):
|
|
53 |
topics.append(f"Topic #{index + 1}: {', '.join(top_terms)}")
|
54 |
return topics
|
55 |
|
|
|
|
|
|
|
|
|
|
|
56 |
# Streamlit UI
|
57 |
st.title("Text Analysis and Topic Modeling")
|
58 |
st.write("Upload a CSV file containing a column with text data.")
|
@@ -92,3 +97,8 @@ if uploaded_file:
|
|
92 |
avg_topic_proportions = topic_proportions.mean(axis=0)
|
93 |
st.subheader("Topic Proportions")
|
94 |
plot_topic_proportions(avg_topic_proportions, lda.components_.shape[0])
|
|
|
|
|
|
|
|
|
|
|
|
53 |
topics.append(f"Topic #{index + 1}: {', '.join(top_terms)}")
|
54 |
return topics
|
55 |
|
56 |
+
def display_document_topic_distribution(topic_proportions):
|
57 |
+
topic_df = pd.DataFrame(topic_proportions, columns=[f"Topic {i+1}" for i in range(topic_proportions.shape[1])])
|
58 |
+
topic_df['Dominant Topic'] = topic_df.idxmax(axis=1)
|
59 |
+
return topic_df
|
60 |
+
|
61 |
# Streamlit UI
|
62 |
st.title("Text Analysis and Topic Modeling")
|
63 |
st.write("Upload a CSV file containing a column with text data.")
|
|
|
97 |
avg_topic_proportions = topic_proportions.mean(axis=0)
|
98 |
st.subheader("Topic Proportions")
|
99 |
plot_topic_proportions(avg_topic_proportions, lda.components_.shape[0])
|
100 |
+
|
101 |
+
# Display document topic distribution
|
102 |
+
st.subheader("Document Topic Distribution")
|
103 |
+
document_topic_distribution = display_document_topic_distribution(topic_proportions)
|
104 |
+
st.write(document_topic_distribution.head())
|