Qu

ablation_study

Builtin index · Statistics & ML

result = ablation_study(X, y, [cv_folds=3])

Input: X, y, cv_folds · Output: result

What it is

Computes one importance score per feature column of an N-row, D-column X and length-N y, using cv_folds folds (integer, default 3): the full model's cross-validated score minus the score of the same model refit without that column.

Overloads

2 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.

CodeInputOutputDescription
result = ablation_study(X, y, [cv_folds=3])
X —Computes one importance score per feature column of an N-row, D-column X and length-N y, using cv_folds folds (integer, default 3): the full model's cross-validated score minus the score of the same model refit without that column.
y —With no kind= given, ablation_study cross-validates a classifier and scores by accuracy -- correct only when y really is a set of discrete labels.
cv_folds optional (default 3)Computes one importance score per feature column of an N-row, D-column X and length-N y, using cv_folds folds (integer, default 3): the full model's cross-validated score minus the score of the same model refit without that column.
result vector
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Xac = randn(60, 2, seed = 91)
yac = zeros(60)
for i in 0 to 59
    if Xac[i, 0] + Xac[i, 1] > 0
        yac[i] = 1
    end if
end for
print("ablation_study, default kind (classification): {round(ablation_study(Xac, yac, cv_folds = 3), 4)}")
output
ablation_study, default kind (classification): [0.1667, 0.15]
CodeInputOutputDescription
result = ablation_study(X, y, [cv_folds=3])
X —Computes one importance score per feature column of an N-row, D-column X and length-N y, using cv_folds folds (integer, default 3): the full model's cross-validated score minus the score of the same model refit without that column.
y —Skip this on a continuous y and you hit the exact silent-nonsense trap the default invites:.
cv_folds optional (default 3)Computes one importance score per feature column of an N-row, D-column X and length-N y, using cv_folds folds (integer, default 3): the full model's cross-validated score minus the score of the same model refit without that column.
result vector
kind = "regression" switches the internal model and score to R².

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Xar = randn(60, 3, seed = 94)
betar = [2.0, -1.0, 0.5]
yar = Xar * betar + 0.05 * randn(60, seed = 95)
rk = "regression"
print("default kind on a continuous target: {round(ablation_study(Xar, yar, cv_folds = 3), 4)}")   # wrong! all zero

print("kind=regression on the same target:  {round(ablation_study(Xar, yar, cv_folds = 3, kind = rk), 4)}")
output
default kind on a continuous target: [0, 0, 0]
kind=regression on the same target:  [2.0618, 0.225, -0.0557]

How it works

ablation_study(X, y, [cv_folds=3], [max_depth=3], [seed=], [kind="classification"]) — see ablation_study_scores's own doc comment. Returns one importance score per feature column (full-model CV score minus that feature's own ablated score) — a report, not a selection (unlike rfe, which removes features and keeps going).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.