Automate region-assignment pipelines

Integrate InsideForest 0.4.3 into a repeatable flow with explicit inputs, regional quality diagnostics, and persistence.

Step 1: organize the project

mkdir -p pipelines artifacts

Step 2: define the script

# pipelines/daily_pipeline.py
from pathlib import Path
import pandas as pd
from InsideForest import InsideForestRegionClusterer

TARGET = "target"
train = pd.read_parquet("data/train.parquet")
new = pd.read_parquet("data/new.parquet")

model = InsideForestRegionClusterer(
    rf_params={"random_state": 42},
    seed=42,
    auto_fast=True,
    auto_feature_reduce=True,
)
model.fit(train.drop(columns=TARGET), train[TARGET])

assignments = model.assign_regions(new)
quality = model.region_quality_report(new)

Path("artifacts").mkdir(exist_ok=True)
assignments.to_parquet("artifacts/assignments.parquet")
model.save("artifacts/insideforest.joblib")

The assignment table records cluster -1 for unmatched rows. Persist the quality report beside the model when the pipeline needs an auditable coverage history.

Step 3: validate in CI

python -m pytest tests -q
python pipelines/daily_pipeline.py

Document the process following Reproducibility and share reports with Interpretation.