Labels

Generates reports, metrics, and descriptions for the regions produced by Regions.

Functions

Example

from InsideForest import Labels

labels = Labels()
summary = labels.summaries(clusterized)
descriptions = labels.generate_descriptions(descriptive, feature_names)

branch_summaries = labels.get_labels(
    range_dataframes=priority_ranges,
    df=df,
    target_var="target",
    max_labels=5,
)

for branch in branch_summaries:
    for description, (score, population) in branch.items():
        mean_target, count = score
        print(f"{description} → mean={mean_target:.3f}, size={count}")
        print(population.head())

The interval helpers reuse custom_round to harmonize units and highlight relevant digits. The resulting descriptions and populations can be exported to CSV or Markdown and complement the df_clusters_description_ and df_datos_explain_ attributes exposed by the high-level wrappers.