Skip to content

fit_profiler

The entry point — profiles a fitted model and returns a ProfilingResult. See the Profiling guide for narrative usage.

fit_profiler takes data arguments plus a single typed ProfilingConfig via config=. Pass the fitted model, feature matrix X, cohort mask target_mask, optional ground-truth y, holdout splits, encoding_registry, and task_type directly on the function; put every tuning knob — clustering geometry, archetype filters, rule miners, global explanations, EDA, report output — inside ProfilingConfig. Optional stages are enabled by presence of their section (rules=RulesConfig(...), explanations=ExplanationsConfig(...), …), not boolean flags on fit_profiler. Omit config (or pass ProfilingConfig()) for archetype discovery only.

fit_profiler

fit_profiler(
    *,
    model: Any = None,
    X: DataFrame,
    shap_values: ndarray | None = None,
    predictions: ndarray | None = None,
    target_mask: ndarray | Series | None = None,
    y: ndarray | Series | None = None,
    X_target_orig: DataFrame | None = None,
    id_columns: list[str] | None = None,
    task_type: TaskType = BINARY,
    encoding_registry: EncodingRegistry | None = None,
    target_col: str | None = None,
    X_valid: DataFrame | None = None,
    y_valid: ndarray | Series | None = None,
    X_test: DataFrame | None = None,
    y_test: ndarray | Series | None = None,
    X_holdout: DataFrame | None = None,
    y_holdout: ndarray | Series | None = None,
    holdout_basis: HoldoutBasis | None = None,
    positive_class: Any = None,
    served_threshold: float | None = None,
    config: ProfilingConfig | None = None
) -> ProfilingResult

Discover archetypes in the target class, explain them, and enable similar-case retrieval.

Fits the profiling pipeline over a model (or precomputed SHAP) and returns a populated :class:parleml_mli.ProfilingResult — archetype clusters plus, when their sections are configured, mined rules, global explanations, EDA, and a written report. For a generic estimator or predictions-only input use :func:parleml_mli.monitor_predictions instead.

All tuning knobs live in a single typed :class:parleml_mli.ProfilingConfig (config); the arguments here are strictly the run's data.

Parameters:

Name Type Description Default
model fitted native estimator

Must be recognised by :func:parleml_mli.adapters.detect_model_type (CatBoost / LightGBM / XGBoost / sklearn ensemble / tree / HGB / GLM / EBM / RuleFit). May be None when shap_values are supplied.

None
X DataFrame

Full training feature matrix (required).

required
shap_values ndarray

Raw/logit SHAP (n_samples, n_features); auto-computed when None.

None
predictions ndarray

Model scores (n_samples,); auto-computed when None.

None
target_mask ndarray or Series

Boolean mask (True = target). None profiles the positive class of a binary y (every row when there is no binary y).

None
y ndarray or Series

Ground-truth labels / regression targets aligned with X. Enables ground-truth-aware per-archetype stats and holdout evaluation.

None
X_target_orig DataFrame

Pre-aligned original (clean) features for the target population, stored on the result for signatures, reports, and retrieval.

None
id_columns list[str]

Identifier columns (from X_target_orig) always surfaced in representative-example tables and retrieval output.

None
task_type TaskType

BINARY (default) or REGRESSION.

BINARY
encoding_registry EncodingRegistry

Describes what each engineered column means; bound to X.columns at fit time. Defaults to an identity registry.

None
target_col str

Name of the target column y was built from (folded into the registry so target-encoder columns are recognised).

None
X_valid optional

Holdout splits aligned with X. When supplied, the fitted model scores them into a :class:parleml_mli.evaluation.ModelEvaluationResult on result.model_evaluation_.

None
y_valid optional

Holdout splits aligned with X. When supplied, the fitted model scores them into a :class:parleml_mli.evaluation.ModelEvaluationResult on result.model_evaluation_.

None
X_test optional

Holdout splits aligned with X. When supplied, the fitted model scores them into a :class:parleml_mli.evaluation.ModelEvaluationResult on result.model_evaluation_.

None
y_test optional

Holdout splits aligned with X. When supplied, the fitted model scores them into a :class:parleml_mli.evaluation.ModelEvaluationResult on result.model_evaluation_.

None
X_holdout optional

Held-out rows — rows the rule search never saw, and ideally the model neither (holdout_basis says which) — in X's feature space, with labels like y (a label outside the model's classes counts against every rule). Every mined rule set gets its Test numbers and holds-up verdict there (:mod:parleml_mli.rules.scoring); nothing else reads them.

None
y_holdout optional

Held-out rows — rows the rule search never saw, and ideally the model neither (holdout_basis says which) — in X's feature space, with labels like y (a label outside the model's classes counts against every rule). Every mined rule set gets its Test numbers and holds-up verdict there (:mod:parleml_mli.rules.scoring); nothing else reads them.

None
holdout_basis HoldoutBasis

Where the held-out rows come from, stamped on every rule set.

None
positive_class optional

The positive label of a binary y; resolved with :func:parleml_mli.core.target.resolve_target (defaults to model.classes_[1], else True / 1 / the last sorted label) and stored on result.target_.

None
served_threshold float

The deployed model's published binary cut on these predictions' scale; wins over config.evaluation.decision_threshold.

None
config ProfilingConfig

All tuning knobs, composed from small frozen section dataclasses (clustering / archetypes / runtime / evaluation plus the optional rules / explanations / eda / report sections — a None optional section skips that stage). None (default) uses ProfilingConfig(): archetype discovery only. See the configuration reference.

None

Returns:

Type Description
ProfilingResult

The populated result; also written to report.output_dir when the report section sets one.