(df)
| 8 | from utils import REGION_COORDINATES |
| 9 | |
| 10 | def 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 | |
| 30 | def regional_clustering(df, n_clusters): |
| 31 | try: |
no test coverage detected