Performance Tips
InsideForest includes automated heuristics, but tuning a few parameters can significantly improve runtime and memory usage. Use the following guidelines when working with large datasets.
Leverage auto presets
auto_fast=True: enables internal shortcuts that reduce the number of evaluated regions and increases sampling efficiency.auto_feature_reduce=True: keeps only the most discriminative features per region, lowering dimensionality before clustering.n_sample_multiplierandef_sample_multiplier: control how many samples feed the branch extraction step. Lower values decrease runtime but may miss rare patterns.
Control tree complexity
- Limit
max_depthormin_samples_leafin the underlying forest to avoid overly fragmented branches. - Use
rf_paramsto pass customRandomForestsettings such asn_estimators,max_features, or bootstrapping. - Reuse an existing forest when you already have a calibrated model; this skips training time completely.
Batch predictions
- InsideForest estimators accept NumPy arrays, pandas DataFrames, and Spark DataFrames.
- For pandas inputs, call
predict,transform, orassign_regionsin batches to control membership-matrix memory. - The region clusterers do not expose
predict_proba. Read class distributions fromregions_; inspectforest_separately only when diagnosing the branch generator.
Control the number of regions
- Raise
leaf_percentileormin_supportto retain fewer, stronger class regions. - Use
max_regions_per_classto bound class-aware output size. - Keep
branch_aggregation="none"unless a validated aggregation strategy meets compression, coverage, AMI, purity, stability, and runtime criteria.
Monitor feature importance
- Inspect
feature_importances_to spot features that dominate rules. Consider removing low-signal columns to simplify the search space. - Combine
auto_feature_reducewith domain knowledge to cap the maximum number of conditions per region.
Persist intermediate artifacts
- Call
saveon clusterers or regressors to store the forest, regions, and metadata. Reload them withloadto resume analysis. - Export region descriptions to CSV or JSON using
generate_descriptionsfor downstream dashboards.
Validate with experiments
Use the recommendations in Experiments & Benchmarks to design reproducible evaluations before moving to production.