MCPcopy Create free account
hub / github.com/Hrishikesh332/HCDS-EPD / clustering_analysis

Function clustering_analysis

nav/clustering.py:10–28  ·  view source on GitHub ↗
(df)

Source from the content-addressed store, hash-verified

8from utils import REGION_COORDINATES
9
10def clustering_analysis(df):
11 st.markdown('<h1 class="main-header">Grouping</h1>', unsafe_allow_html=True)
12 st.markdown("""
13 This page uses <b>hierarchical clustering</b> to group regions and BNF categories based on their cost patterns. Similar groups are placed together to help you spot patterns and similarities.
14 """, unsafe_allow_html=True)
15
16 n_clusters = st.slider("Groups", 2, 6, 4)
17
18 try:
19 regional_clustering(df, n_clusters)
20 except Exception as e:
21 st.error(f"Error: {str(e)}")
22 st.markdown("---")
23 st.subheader("BNF Category Grouping")
24 n_cat_clusters = st.slider("Category Groups", 2, 6, 4, key="cat_clusters")
25 try:
26 bnf_category_clustering(df, n_cat_clusters)
27 except Exception as e:
28 st.error(f"Error in BNF category grouping: {str(e)}")
29
30def regional_clustering(df, n_clusters):
31 try:

Callers 1

route_to_pageFunction · 0.90

Calls 2

regional_clusteringFunction · 0.85
bnf_category_clusteringFunction · 0.85

Tested by

no test coverage detected