matlab/matlab-agentic-toolkit / skills-catalog/ai-and-statistics/matlab-interpret-machine-learning-model
matlab-interpret-machine-learning-model
UnverifiedInterpret and explain a trained tabular machine-learning model (classification or regression) in MATLAB. Find which predictors, features, or columns matter most; explain why the model made a specific prediction, including diagnosing predictions it got wrong; show how a predictor affects the output; and compare how the model behaves across cohorts or subgroups. Uses model-agnostic techniques and model-native measures, and works on custom models (such as a dlnetwork) through a prediction function handle. Use for model interpretability, explainability, and feature-importance questions on tabular data, not for training, tuning, feature selection, deploying models, or models trained on image, text, signal, or other non-tabular data.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 31.8 KB |
| manifest.yaml | config | 556 B |
| references/agnostic-effect-shape.md | markdown | 6.8 KB |
| references/agnostic-global-importance.md | markdown | 9.6 KB |
| references/agnostic-local-explanation.md | markdown | 6.6 KB |
| references/cohort-analysis.md | markdown | 4.5 KB |
| references/custom-model-wrapper.md | markdown | 9.4 KB |
| references/native-importance-measures.md | markdown | 9.9 KB |
| scripts/functionHandleMap.m | other | 3.9 KB |
scripts/functionHandleMap.m
View on GitHubfunction map = functionHandleMap(mdl)
%functionHandleMap For a given model, how must it be passed to each
% interpretability function.
%
% MAP = functionHandleMap(MDL) returns a table with one row per function:
% Function - name of the interpretability function
% NeedsFunctionHandle - for THIS model:
% "no" built-in model works directly
% "yes" must be wrapped as a handle
% "not supported" cannot be used with MDL at all
%
% Model matching uses documented (short) class names. A full model has its
% Compact* class as a superclass (e.g. ClassificationSVM is a
% CompactClassificationSVM), so listing the compact short name matches both
% the full and compact forms. NOTE: isa() with an unqualified short name
% does NOT see packaged superclasses, so matching is done against the
% package-stripped class + superclass names of MDL instead of isa().
%
% Example:
% load fisheriris
% svm = fitcsvm(meas(1:100,:), species(1:100));
% functionHandleMap(svm)
% Copyright 2026 The MathWorks, Inc.
isHandle = isa(mdl, "function_handle");
% Package-stripped class + superclass names of MDL (empty for a handle).
if isHandle
hierarchy = strings(0,1);
else
hierarchy = string(regexprep([{class(mdl)}; superclasses(mdl)], '.*\.', ''));
end
% Documented built-in classes accepted directly, by group (compact names).
classif = ["CompactClassificationTree" "CompactClassificationSVM" ...
"CompactClassificationEnsemble" "CompactClassificationDiscriminant" ...
"CompactClassificationNaiveBayes" "CompactClassificationNeuralNetwork" ...
"CompactClassificationGAM" "CompactClassificationECOC" ...
"CompactClassificationXGBoost" "ClassificationKNN" ...
"ClassificationLinear" "ClassificationKernel"];
regr = ["CompactRegressionTree" "CompactRegressionSVM" ...
"CompactRegressionEnsemble" "CompactRegressionGP" "CompactRegressionGAM" ...
"CompactRegressionNeuralNetwork" "CompactRegressionXGBoost" ...
"RegressionLinear" "RegressionKernel"];
statsRegr = ["CompactLinearModel" "CompactGeneralizedLinearModel" ...
"NonLinearModel" "LinearMixedModel" "GeneralizedLinearMixedModel"];
bagger = ["TreeBagger" "CompactTreeBagger"];
isClassif = iAny(hierarchy, classif);
isRegr = iAny(hierarchy, regr);
isPD = isClassif || isRegr || iAny(hierarchy, statsRegr) || iAny(hierarchy, bagger);
isCF = isClassif && ~iAny(hierarchy, "CompactClassificationECOC") && iBinary(mdl);
% Registry: {function, supportsHandle, isBuiltInForThisModel}
reg = {
"counterfactuals" , false, isCF
"lime" , true , isClassif || isRegr
"shapley" , true , isClassif || isRegr
"partialDependence" , true , isPD
"plotPartialDependence" , true , isPD
"permutationImportance" , false, isClassif || isRegr
};
n = size(reg, 1);
name = strings(n,1);
needs = strings(n,1);
for k = 1:n
name(k) = reg{k,1};
supportsHandle = reg{k,2};
isBuiltIn = reg{k,3};
if isBuiltIn
needs(k) = "no"; % built-in works directly
elseif supportsHandle
needs(k) = "yes"; % wrap as a handle
else
needs(k) = "not supported"; % cannot use this model
end
if isHandle && supportsHandle
needs(k) = "no"; % already a handle
end
end
map = table(name, needs, ...
'VariableNames', {'Function','NeedsFunctionHandle'});
end
function tf = iAny(hierarchy, classes)
tf = any(ismember(classes, hierarchy));
end
function tf = iBinary(mdl)
tf = isprop(mdl, "ClassNames") && numel(mdl.ClassNames) == 2;
end
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 117k | Updated | Claude CodeCodex | Unverified | Install |