Labels
Generates reports, metrics, and descriptions for the regions produced by Regions.
Functions
generate_descriptions(region_df, feature_names): produces short text per cluster.categorize_conditions(descriptions): groups conditions by type.summaries(clusterized): coverage, purity, and size metrics.custom_round(number): rounds magnitudes for human-readable reports.get_intervals(interval_df): composes textual descriptions from branch bounds.get_labels(range_dataframes, df, target_var, max_labels=9, num_branches=10): generates interval descriptions, average target values, and full populations for the most relevant branches.
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.