Mattral commited on
Commit
bc8b213
·
verified ·
1 Parent(s): 8d04a78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -3,7 +3,8 @@ import streamlit as st
3
  from difflib import SequenceMatcher
4
  from sklearn.feature_extraction.text import TfidfVectorizer
5
  from sklearn.metrics.pairwise import cosine_similarity
6
- from Levenshtein import distance as levenshtein_distance
 
7
 
8
 
9
  ms = st.session_state
@@ -98,7 +99,13 @@ def find_similar_texts(df1, df2, column_name, threshold=0.3):
98
 
99
  return similar_texts, exact_matches
100
 
101
-
 
 
 
 
 
 
102
 
103
 
104
  def main():
@@ -154,6 +161,19 @@ def main():
154
  st.write(f"____________________")
155
  st.write()
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  if __name__ == "__main__":
159
  main()
 
3
  from difflib import SequenceMatcher
4
  from sklearn.feature_extraction.text import TfidfVectorizer
5
  from sklearn.metrics.pairwise import cosine_similarity
6
+ from Levenshtein import distance as
7
+ import matplotlib.pyplot as plt
8
 
9
 
10
  ms = st.session_state
 
99
 
100
  return similar_texts, exact_matches
101
 
102
+ def plot_correlation(df, column):
103
+ plt.figure(figsize=(8, 6))
104
+ plt.scatter(df.index, df[column])
105
+ plt.xlabel("Index")
106
+ plt.ylabel(column)
107
+ plt.title(f"Correlation Plot of {column}")
108
+ st.pyplot()
109
 
110
 
111
  def main():
 
161
  st.write(f"____________________")
162
  st.write()
163
 
164
+ # Calculate correlation
165
+ if warehouse_df[warehouse_column].dtype != "object" and industry_df[industry_column].dtype != "object":
166
+ correlation = warehouse_df[warehouse_column].corr(industry_df[industry_column])
167
+ st.header("Correlation")
168
+ st.write(f"The correlation between {warehouse_column} in warehouse item stocks and {industry_column} in industry item stocks is: {correlation}")
169
+
170
+ # Show correlation plot for each dataset
171
+ if st.button("Show for each dataset"):
172
+ st.subheader("Correlation Plot for Warehouse Dataset")
173
+ plot_correlation(warehouse_df, warehouse_column)
174
+
175
+ st.subheader("Correlation Plot for Industry Dataset")
176
+ plot_correlation(industry_df, industry_column)
177
 
178
  if __name__ == "__main__":
179
  main()