AMKhakbaz commited on
Commit
a977207
·
verified ·
1 Parent(s): 9e4c0ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -840,9 +840,6 @@ try:
840
 
841
  elif main_option == "Segmentation Analysis":
842
  st.header("Segmentation Analysis")
843
-
844
- cols = edit_strings(df.columns)
845
- cols = sorted(list(set(cols)))
846
 
847
  st.sidebar.header("Selection of questions")
848
  single_list = st.sidebar.multiselect(
@@ -850,34 +847,37 @@ try:
850
  cols,
851
  default=[]
852
  )
853
-
854
  multi_list = st.sidebar.multiselect(
855
  'Multi answer questions',
856
  cols,
857
  default=[]
858
  )
859
-
860
  score_list = st.sidebar.multiselect(
861
  'Score answer questions',
862
  cols,
863
  default=[]
864
  )
865
-
866
  matching_cols1 = []
867
  for i in multi_list:
868
  matching_cols1 += [col for col in df.columns if is_matching_pattern(col, i)]
869
-
870
  df_clean = process_dataframe(df[single_list + matching_cols1])
871
  st.subheader("Selected Table")
872
  st.dataframe(df_clean)
873
 
874
- linkage_method = st.sidebar.selectbox("Select the Linkage Method of Segmentation Analysis:", ["Hierarchical Clustering"])
875
-
876
- df_cluster = hierarchical_clustering_with_plotly(df_clean, linkage_method)
 
 
 
 
877
 
878
  st.subheader("Cluster Table")
879
  st.dataframe(df_clean)
880
-
881
 
882
  elif main_option == "Hypothesis test":
883
  st.header("Hypothesis Testing")
 
840
 
841
  elif main_option == "Segmentation Analysis":
842
  st.header("Segmentation Analysis")
 
 
 
843
 
844
  st.sidebar.header("Selection of questions")
845
  single_list = st.sidebar.multiselect(
 
847
  cols,
848
  default=[]
849
  )
850
+
851
  multi_list = st.sidebar.multiselect(
852
  'Multi answer questions',
853
  cols,
854
  default=[]
855
  )
856
+
857
  score_list = st.sidebar.multiselect(
858
  'Score answer questions',
859
  cols,
860
  default=[]
861
  )
862
+
863
  matching_cols1 = []
864
  for i in multi_list:
865
  matching_cols1 += [col for col in df.columns if is_matching_pattern(col, i)]
866
+
867
  df_clean = process_dataframe(df[single_list + matching_cols1])
868
  st.subheader("Selected Table")
869
  st.dataframe(df_clean)
870
 
871
+ selected_method = st.sidebar.selectbox("Select the Linkage Method of Segmentation Analysis:", ['Hierarchical Clustering', 'K-means Clustering'])
872
+ if selected_method = 'Hierarchical Clustering':
873
+ linkage_method = st.sidebar.selectbox("Select the Linkage Method of Segmentation Analysis:", ['average', 'single', 'complete', 'weighted', 'centroid', 'median', 'ward'])
874
+ df_cluster = hierarchical_clustering_with_plotly(df_clean, linkage_method)
875
+ if selected_method = 'K-means Clustering':
876
+ k = int(st.text_input("Enter the desired number of clusters"))
877
+ df_clean = kmeans_clustering(df, k)
878
 
879
  st.subheader("Cluster Table")
880
  st.dataframe(df_clean)
 
881
 
882
  elif main_option == "Hypothesis test":
883
  st.header("Hypothesis Testing")