PythiloLesson 7 of 12 · progress kept in this browser

Measure reliance on a feature using held-out loss

A feature can be strongly associated with an outcome without a trained model relying on it. Permutation importance measures the change in held-out loss when one feature's alignment with the outcomes is disrupted. It evaluates the particular fitted model and test population.

This exercise uses a deterministic one-position rotation as an inspectable perturbation. It is one reference experiment, not a full estimate with repeated random permutations and uncertainty. Correlated features may substitute for each other, so low importance does not establish irrelevance or causality. Never refit the model on the perturbed evaluation data.

rows=[[1,10],[2,20],[3,30]]
rotated=[r[:] for r in rows]
column=[r[0] for r in rows]
for i,row in enumerate(rotated):row[0]=column[(i+1)%3]
print(rows,rotated)
Your task

Implement rotated_importance(predict,rows,targets,column). Return perturbed MSE minus baseline MSE, rotating the chosen column by one row. Require nonempty matching row/target counts and a valid column in every row. Do not mutate rows.