Cluster selector helpers

The InsideForest.cluster_selector module exposes utilities that rebalance or consolidate clusters produced by Regions.labels. Instead of a single ClusterSelector class, use the dedicated functions and classes described below.

Key utilities

Example

from InsideForest import cluster_selector

# After calling InsideForestRegionClusterer(..., get_detail=True).fit(X, y)
menu = cluster_selector.MenuClusterSelector(quota=0.2)
menu.fit(clf.df_reres_, y)
rebalanced = menu.predict(clf.df_reres_)

# Alternatively apply a functional helper
balanced = cluster_selector.balance_lists_n_clusters(clf.df_reres_, seed=42)

All helpers operate on the DataFrame returned by Regions.prio_ranges, which is stored as df_reres_ inside the high-level wrappers when get_detail=True.