Classifies tabular data end-to-end in MATLAB: loads, cleans, selects classifiers, trains, and compares accuracies via cross-validation, holdout, or hyperparameter optimization with statistical tests.
Ships in ai-and-statistics. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Compare classifiers on the user's dataset and identify the top tier of models that are statistically equivalent in accuracy. The workflow below runs in order; each step that says STOP loads a file from references/ with the Read tool before any code for that step. Those files are not separate skills.
fitr* functions, or the Regression Learner app through matlab-use-machine-learning-apps.matlab-use-machine-learning-apps.matlab-interpret-machine-learning-model or matlab-engineer-tabular-features.matlab-train-network, or extract tabular features first with matlab-engineer-tabular-features.matlab-train-network. This skill includes fitcnet as one candidate but does not tune network layers.predict on that model directly.fitc* directly with the 'Prior' or 'Cost' name-value pair; this skill's statistical-comparison workflow will not give correct results in that setting."Run all MATLAB code via the MATLAB MCP server (mcp__matlab__evaluate_matlab_code, or mcp__matlab__run_matlab_file for scripts). Set project_path to this skill's scripts/helpers/ directory so the helpers resolve on the current folder without addpath. Every helper, its signature and the shared variable names are in references/helpers.md; read it before Step 1.
STOP. Use the Read tool on references/communication.md and references/helpers.md. Talk to the user about their data and results, never about this skill's files or internal steps.
skillPath = fileparts(fileparts(pwd)); in the first code block (the skill root; pwd is scripts/helpers/).scripts/README.md.hasHoldout = true and assign XTrain, YTrain, XTest, YTest. Otherwise assign X, Y; do not split or ask about splitting yet.If any predictor is categorical, X must be a table with those columns stored as categorical, string or cellstr. Assemble separate mixed-type variables with table(...); never concatenate them into a numeric matrix, which turns categories into numeric codes.
STOP. Use the Read tool on references/dataprep.md. Do NOT write any MATLAB code until you have read that file. Follow its instructions exactly as written.
Run it on XTrain/YTrain when hasHoldout, else on X/Y. On return the workspace holds flags (from compute_data_flags) and a preproc struct array recording every change to X or Y in order. Use only the op names that file lists (omitColumns, dropZeroVariance, removeClasses, mergeClasses); the exported Step 14 script cannot replay any other.
If hasHoldout = true (dataset came with a separate test set): skip this step.
Otherwise, load the thresholds and use flags.smallestClassSize (computed in Step 2) to present a recommendation:
run(fullfile(skillPath, 'scripts', 'model_catalog', 'classifier_thresholds.m')); % populates THRESHOLDS
If flags.smallestClassSize > THRESHOLDS.holdout_smallest_class, recommend a 70/30 holdout split. Interpolate the actual threshold into the prompt via sprintf — do not hardcode the number:
This dataset has [flags.N] observations and the smallest class has [flags.smallestClassSize] observations — larger than the [THRESHOLDS.holdout_smallest_class]-observation threshold for holdout evaluation. I recommend a 70/30 stratified train/test split. This is faster and evaluates on unseen data.
Alternatively, I can use 5-fold cross-validation. CV uses all data for both training and evaluation but is slower.
Which do you prefer? (holdout / cv)
Otherwise (flags.smallestClassSize <= THRESHOLDS.holdout_smallest_class), recommend cross-validation:
This dataset has [flags.N] observations and the smallest class has [flags.smallestClassSize] observations — at or below the [THRESHOLDS.holdout_smallest_class]-observation threshold for a reliable holdout split. I recommend 5-fold cross-validation.
Alternatively, I can use a 70/30 stratified holdout split, though the test set may be small.
Which do you prefer? (cv / holdout)
Wait for the user's response. If the user chooses holdout, create the split with make_holdout_split and set hasHoldout = true. If the user chooses cv, set hasHoldout = false and create the folds: cvp = cvpartition(Y, 'KFold', 5, 'Stratify', true);
All subsequent steps operate on the training data (XTrain/YTrain when hasHoldout, or X/Y otherwise).
Before selecting models, ask the user:
How important is model interpretability for this task? (low / high)
Record the answer as interpretability ('low' or 'high'). high: predictions must be explainable to a human (trees, discriminant analysis, logistic regression). low: accuracy is the priority; all model families are candidates.
STOP. Use the Read tool on references/select-classifiers.md. Do NOT write any MATLAB code until you have read that file. Follow its instructions exactly as written.
The model list build_model_definitions returns is exhaustive: do not add models it does not produce. The only allowed changes are the interpretability filter, the imbalanced-data overlay, and explicit user requests.
If flags.isImbalanced, also Read references/select-classifiers-imbalanced.md for the boosting overlay, the mandatory uniform-prior decision, and the extreme-imbalance advisory.
Extreme imbalance: when that reference's advisory condition holds, send the advisory as a chat message before Step 6 and wait for the answer. In a non-interactive session, include the advisory in your reply and say which choice you applied. In an interactive session, pose the uniform-prior question verbatim and wait for the answer before any fit* call. In a non-interactive session where you have been told not to prompt, still surface the choice: name both options (Prior='uniform' vs Prior='empirical'), say which one you are using and why, and note that this is normally the user's call. Silently defaulting — even when the domain (fraud detection, medical screening) makes one option sound obvious — is a hard failure of the imbalanced workflow.
% Training data: XTrain/YTrain on the holdout path, X/Y on the CV path.
flags.interp = interpretability;
flags.totalCatLevels = count_categorical_levels(XTrain);
modelDefs = build_model_definitions(flags, skillPath, 'X', XTrain, 'Y', YTrain);
% Imbalanced data: run(fullfile(skillPath, 'scripts', 'model_catalog', 'imbalanced_boosting.m'));
% then add 'ImbalancedOverlay', IMBALANCED_BOOSTING_MODELS and, on the CV path, 'UseUniformPrior', useUniformPrior.
modelNames = {modelDefs.name};
Multiclass ECOC recipes appear twice (-OVO and -OVA). Train every entry. Never type a fitc* or fitensemble call to train these models: the correct fit call is baked into modelDefs(k).cvFitFcn (CV path) and modelDefs(k).template (holdout path).
STOP. Use the Read tool on references/training.md. Do NOT write any MATLAB code for this step until you have read that file. Follow its instructions exactly as written.
It covers the mandatory static check gate, the training loop for each path (train_and_score_cv with cvp, or train_and_score_holdout), and the per-model results table with 95% confidence intervals.
CV path (hasHoldout = false): run a Friedman omnibus test on foldAcc first, then proceed to pairwise testckfold in Step 8. Do not follow Friedman with multcompare — pairwise comparisons come from testckfold.
[pFriedman, tbl, stats] = friedman(foldAcc, 1, 'off');
Holdout path (hasHoldout = true): skip Friedman (no folds exist); proceed directly to pairwise testcholdout in Step 8.
alpha_corrected = 0.05 / nchoosek(nModels, 2).[~, bestIdx] = max(acc); topTierIdx = find(~hMatrix(bestIdx, :));Do NOT hand-write the pairwise loop. Both helpers seed the diagonal with 1.
% CV path: testckfold (5x2 F-test), under the run's prior, each pair seeded
[pvalMatrix, hMatrix, cmpInfo] = compute_pairwise_pvalues_cv(modelDefs, X, Y, alpha_corrected, 'UseUniformPrior', useUniformPrior);
% Holdout path: testcholdout (McNemar) on the stored prediction vectors
[pvalMatrix, hMatrix] = compute_pairwise_pvalues_holdout(YHat, YTest, alpha_corrected);
On the CV path, if cmpInfo.reason is not empty (sparse X too large to densify), tell the user cmpInfo.reason and name cmpInfo.test as the test used.
ALWAYS show the p-value matrix as a heatmap, on both paths:
plot_pvalue_heatmap(pvalMatrix, modelNames, sprintf('Pairwise testckfold p-values (Friedman p = %.4f)', pFriedman)); % CV path
plot_pvalue_heatmap(pvalMatrix, modelNames, 'Pairwise testcholdout p-values (McNemar)'); % holdout path
Show two figures by calling plot_accuracy_bars and plot_training_time. Both sort models by descending accuracy and highlight top-tier models.
evalPath = 'cv'; if hasHoldout, evalPath = 'holdout'; end
plot_accuracy_bars(modelNames, acc, accCI, topTierIdx, ...
sprintf('Accuracy with 95%% CI (path: %s)', evalPath));
plot_training_time(modelNames, trainTime, acc, topTierIdx);
If modelDefs contains boosting models (fitcensemble with Method RUSBoost, LogitBoost, AdaBoostM1, AdaBoostM2 or GentleBoost):
STOP. Use the Read tool on references/boosting.md. Follow its instructions exactly as written — learning curves, the resume question, updating the model definition, re-testing only the resumed models' pairs, and redrawing the Step 8 and Step 9 figures.
Ask whether to run HPO and on which models. Print the top tier and the other models as plain chat text, each numbered by its position in modelNames so the user can answer with numbers, then ask. Mention that HPO on the CV path uses nested cross-validation and can be slow. If the user declines, go to Step 12 without reading references/hpo.md.
Otherwise: STOP. Use the Read tool on references/hpo.md. Do NOT write any MATLAB code until you have read that file. Follow its instructions exactly as written.
Report:
Include the per-model accuracy and 95% CI for every trained model so the user has enough context to decide what to save in Step 13. If Step 11 optimized models on the CV path, say once, unprompted, that the top tier and p-values were computed before optimization and the optimized models were not re-tested.
Consistent metric naming: Pick one of accuracy or error rate and use it consistently throughout the summary. Do NOT mix them — never label an accuracy value with the word "error", or an error value with "accuracy". If you say "lowest mean error", the values reported must be error rates (e.g., 5.1%); if you say "highest mean accuracy", the values must be accuracy (e.g., 94.9%). The same rule applies to confidence intervals.
Offer them in order after the Step 12 summary: Step 13 saves selected models (save_selected_models), Step 14 writes a retraining script (export_workflow_script) and is offered only if models were saved.
STOP. Use the Read tool on references/save-and-export.md. Do NOT write any MATLAB code for these steps until you have read that file. Follow its instructions exactly as written.
build_model_definitions returns; report accuracy with its 95% CI; compare all pairs with Bonferroni correction; record every data change in preproc.fitc* or fitensemble calls to train the models; add models the helper did not return; support custom priors or cost matrices; make generic textbook claims about model properties that the results do not support; recommend a single model for production on accuracy alone.| Function | Used for | Product |
|---|---|---|
testckfold | Pairwise 5×2 CV F-test (CV path) | Statistics and Machine Learning Toolbox |
testcholdout | Pairwise McNemar test (holdout path) | Statistics and Machine Learning Toolbox |
friedman | Omnibus test across folds (CV path) | Statistics and Machine Learning Toolbox |
binofit | Clopper-Pearson 95% CI of accuracy | Statistics and Machine Learning Toolbox |
cvpartition | Stratified folds and holdout split | Statistics and Machine Learning Toolbox |
bestPoint | Settings of an optimized model | Statistics and Machine Learning Toolbox |
templateNeuralNetwork | Neural network template (R2026b+; earlier releases use a fitcnet placeholder) | Statistics and Machine Learning Toolbox |
references/helpers.md — every helper's signature and the shared workflow variables (read before Step 1)references/communication.md — how to talk to the user while running (read before Step 1)references/dataprep.md — Step 2; references/select-classifiers.md and references/select-classifiers-imbalanced.md — Step 5; references/training.md — Step 6; references/boosting.md — Step 10; references/hpo.md — Step 11; references/save-and-export.md — Steps 13 and 14references/README.md — layout of references/, scripts/helpers/ and scripts/model_catalog/scripts/README.md — code-level rulesscripts/helpers/ — the functions the workflow calls; scripts/model_catalog/ — branch tables read only by build_model_definitions (do not read them)Copyright 2026 The MathWorks, Inc.
manifest.yaml (opens in a new tab)references/README.md (opens in a new tab)references/boosting.md (opens in a new tab)references/communication.md (opens in a new tab)references/dataprep.md (opens in a new tab)references/helpers.md (opens in a new tab)references/hpo.md (opens in a new tab)references/save-and-export.md (opens in a new tab)references/select-classifiers-imbalanced.md (opens in a new tab)references/select-classifiers.md (opens in a new tab)references/training.md (opens in a new tab)scripts/README.md (opens in a new tab)scripts/helpers/aggregate_nested_cv_loss.p (opens in a new tab)scripts/helpers/apply_preproc.p (opens in a new tab)scripts/helpers/build_model_definitions.m (opens in a new tab)scripts/helpers/compute_data_flags.p (opens in a new tab)scripts/helpers/compute_pairwise_pvalues_cv.p (opens in a new tab)scripts/helpers/compute_pairwise_pvalues_holdout.m (opens in a new tab)scripts/helpers/count_categorical_levels.p (opens in a new tab)scripts/helpers/drop_unseen_test_classes.p (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/ai-and-statistics:matlab-classify-tabular-datafrom ai-and-statistics
npx claudepluginhub matlab/matlab-agentic-toolkit --plugin ai-and-statistics10 skills in this plugin
/matlab-analyze-reliabilityUse this skill when fitting accelerated life models, computing mean time to failure (MTTF), B10 life and similar quantities, fitting life distributions like Weibull for reliability analysis, comparing distribution fits, computing confidence intervals on reliability quantities with bootstrapping, performing lifetime prediction, computing failure rates, plotting Kaplan-Meier curves, computing survival functions, or doing reliability analysis./matlab-deploy-embedded-aiDeploy AI models to embedded hardware using MathWorks tools (MATLAB, Simulink, Embedded Coder). Covers two workflow patterns: (1) MathWorks-native or imported models rebuilt as dlnetwork for lean hardware, (2) direct C/C++ code generation from PyTorch and LiteRT models. Both patterns support all targets (Cortex-M/A/R, x86, GPU). Trigger when: user wants to deploy AI to embedded targets; generate C/CUDA from neural networks; compress AI models for MCU; integrate AI in Simulink for system-level simulation; import PyTorch/ONNX/TensorFlow models for embedded deployment; optimize AI for resource-constrained hardware; or use loadPyTorchExportedProgram, loadLiteRTModel, importNetworkFromPyTorch, importNetworkFromONNX, importNetworkFromTensorFlow, importNetworkFromKeras, dlquantizer, exportNetworkToSimulink, or Embedded Coder with AI models.
/matlab-engineer-tabular-featuresUse when engineering or selecting the best features for single-response classification or regression in MATLAB, whatever the data's modality — for non-tabular data it routes extraction to a domain skill, then selects, assesses, and delivers on the resulting table. Not for multi-response problems, model training, or raw data acquisition.
/matlab-fit-curveFit curves and surfaces interactively with the Curve Fitter app for a complete no-code fitting workflow. Invoke this skill when the Curve Fitter app, cftool, curveFitter, or "curve fitting tool/app" is mentioned in any way. Also use when exploring or comparing fit types (regression, interpolation, smoothing, splines, custom equations); excluding outliers interactively; iterating on a fitting workflow; help choosing a fit type; and exporting to a figure, generating MATLAB code, fits to the workspace, and to Simulink Lookup Tables./matlab-import-external-ai-modelImport PyTorch, ONNX, or Keras 3 / TensorFlow 2.16+ deep learning models into MATLAB as dlnetwork objects. Use when importing .pt2 exported programs, traced .pt files, .onnx models, or Keras 3 models via matlabsaver. Covers importNetworkFromPyTorch, importNetworkFromONNX, importNetworkFromKeras, importNetworkFromTensorFlow, torch.export.export, PyTorchInputSizes, InputDataFormats, matlabsaver, tf_keras downgrade, numeric validation against PyTorch or ONNX Runtime, and placeholder/custom layer implementation. Applies when user mentions any of these functions, file formats, or encounters import errors, unsupported operator warnings, 0 learnables, or uninitialized networks.
/matlab-interpret-machine-learning-modelInterpret 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.Other plugins' skills for the same job