Trains, compares, and exports machine learning models using Classification Learner or Regression Learner apps in MATLAB. Covers opening apps, loading data, training models, evaluating metrics, comparing results, visualizing plots, testing on held-out data, model interpretability, and exporting trained models via AppController.
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.
mlearnapp.internal.appcontroller.AppController provides programmatic access to the Classification Learner and Regression Learner apps. Use it to interact with learner apps and query their state.
Source (loaded at runtime): <skill-base-directory>/scripts/+mlearnapp/+internal/+appcontroller/AppController.p
| When you need... | Load this file |
|---|---|
| Open/close/save/load app, session setup, create/train/select/delete models, model status, GalleryModels enum | api-session-and-models.md |
| Metrics, model spec queries, toolstrip buttons, set feature selection/PCA/optimizer/cost/hyperparameters | api-metrics-and-options.md |
| Open/configure standard plots, results table, standard plot data getters | api-plots.md |
| PDP, permutation importance, Shapley, LIME, Set Shapley Parameters, explainability plot data getters | api-explainability.md |
| Export methods, command logging, diagnostics | api-export-and-diagnostics.md |
Required: Statistics and Machine Learning Toolbox. Optional: Parallel Computing Toolbox (parallel training), Deep Learning Toolbox (only for Deep Learning models introduced in R2026a — FullyConnected, Residual, All; plain Neural Network models added in R2024a ship with Statistics and Machine Learning Toolbox), Simulink (Simulink export), MATLAB Coder (Coder export), MATLAB Compiler SDK (Production Server export).
fitc*/fitr* functions directlycloseApp('Force', true) without explicit user permission. Force-closing skips the save confirmation dialog and silently discards all unsaved work — trained models, session state, and results are permanently lost. Always prefer closeApp() (without Force) so the user gets a chance to save. Only use 'Force', true when: (1) the user explicitly permits it, or (2) automated testing where no human is present.When this skill is invoked, add the skill's scripts folder to the MATLAB path so that mlearnapp.internal.appcontroller classes are available. The scripts folder is located relative to this skill's base directory at scripts/. Run this via the MATLAB MCP evaluate_matlab_code tool, using the skill's base directory path shown at the top of the skill load message:
addpath('<skill-base-directory>/scripts');
For example, if the skill base directory is C:\MATLAB\AgenticAI\.claude\skills\matlab-use-machine-learning-apps, then:
addpath('C:\MATLAB\AgenticAI\.claude\skills\matlab-use-machine-learning-apps\scripts');
Before starting any workflow, gather the information below so the session can be configured up front without wasted training cycles. Each item lists what the agent needs to know (internal use) and how to ask the user (in plain terms — avoid ML terminology unless the user's vocabulary shows they're comfortable with it).
exportModelTo* — workspace, Simulink, Coder, Production Server, Experiment Manager, or exploratory. Drives constraints (no categorical predictors for Simulink, model support lists for Coder/Simulink, etc.).Agent needs to know: Set at session open via openApp, fixed for the session — cannot be changed later without starting a new session. The app default is 5-fold CV ('KFold', 5). Pick based on dataset size × training cost:
| Scheme | When to pick | Syntax |
|---|---|---|
| 5-fold CV | Small-medium data (≤few thousand rows), fast models | 'KFold', 5 (default) |
| 20% hold-out | Large data, slow models (ensembles, DL, optimization), or time-constrained | 'HoldOut', 0.2 |
| Resubstitution | User explicitly wants fast iteration without accuracy estimate (training-set accuracy, optimistic) | 'CrossVal', 'off' |
Ask the user: "Two things, since the validation setting is fixed once we start: (1) roughly how many rows does your dataset have, and (2) is there a training time budget I should keep in mind, or is training time not a concern? I'll pick a validation approach that works for both."
importTestData with an existing table, reserve a fraction via TestDataFraction (e.g., 0.2), or skip test entirely. Test data is distinct from validation and is used only once on the final model.ModelSizeMetric (general) or ModelSizeCoderMetric (Coder-specific).Use the answers to configure the session appropriately from the start — choosing the right predictors, validation scheme, model types, and export path without wasted training cycles.
TestDataFraction (e.g., 0.2–0.25) when opening the app, or let the user import test data later. This ensures an unbiased evaluation path is available after training. For openApp syntax and partitioning NV arguments, see references/api-session-and-models.md#opening-the-app.tabulate or groupcounts to detect imbalance; (3) response distribution (regression) — check for skewness or outliers in the response variable that may warrant transformation; (4) outliers in numeric predictors that could skew model performance; (5) constant or near-constant predictors that add no information. Report findings to the user and suggest preprocessing or model choices accordingly.references/skill-guidance-details.md#preprocessing-and-data-leakage.ClassificationRUSBoostedEnsemble (RUSBoost) which is specifically designed for imbalanced data by undersampling the majority class during boosting, (2) adjusting the cost matrix via app.setModelCostMatrix() to penalize misclassification of the minority class more heavily, (3) using Macro F1 or per-class metrics instead of overall accuracy to evaluate model quality — accuracy can be misleading with imbalanced data. Ask the user which class is more important to get right.app.setDefaultFeatureSelectionOptions(...) for all draft models, or app.setModelFeatureSelectionOptions(...) for a specific one. For which ranking method to pick per problem type and goal, see references/skill-guidance-details.md#feature-selection.app.setDefaultPCAOptions('OnOff', true, 'PercentVarianceExplained', 95) to set for all draft models, or app.setModelPCAOptions('OnOff', true, 'PercentVarianceExplained', 95) to target the current/specific model.app.clickResultsTableToolstripButton()) and Compare Results plot (app.openCompareResultsPlot()) to help the user compare models side-by-side. The Results Table shows all validation (and test) metrics in a sortable table. The Compare Results plot visualizes models either as a bar plot for a single metric or on two axes (e.g., accuracy vs prediction speed, or accuracy vs model size) for quick trade-off analysis. Use app.getResultsTableData() and app.getCompareResultsPlotData() to read the data programmatically. Suggest these views before the user picks the best model, so the decision is informed by multiple metrics — not just accuracy. For compare-results plot configuration, see references/api-plots.md#compare-results-plot-configuration-r2024b.references/skill-guidance-details.md#importing-models.Optimizable* preset (e.g., ClassificationOptimizableTree) — duplicating a regular model does not make it optimizable. Default: 'bayesopt' with 30 iterations. Use 'grid' only for exhaustive search over a small space; 'random' for quick exploration of very large spaces. For time-constrained users, set 'HasTrainingTimeLimit', true, 'MaximumTrainingTimeInSeconds', N. See references/skill-guidance-details.md#hyperparameter-optimization for additional detail.app.toggleUseParallelButton()) when: (1) the dataset is large (>10K observations or >50 predictors), (2) training multiple models or running optimization with many iterations, (3) cross-validation with many folds. Suggest background training (app.toggleUseBackgroundTrainingCheckbox()) or parallel ON when the user wants to continue working in MATLAB while models train (check box is only available when user does not have Parallel Computing Toolbox). Note: parallel requires Parallel Computing Toolbox.references/skill-guidance-details.md#model-iteration.app.importTestData() to load test data, then app.clickTestSelectedModelToolstripButton() to evaluate. Report test metrics via app.getCurrentModelTestDataMetrics() so the user can make an informed decision before exporting.references/skill-guidance-details.md#interpretability-plots. For Shapley/LIME configuration API and plot data fields, see references/api-explainability.md.references/skill-guidance-details.md#plots-for-model-analysis.references/skill-guidance-details.md#session-management.app.clickGenerateCodeToolstripButton() turns the app workflow into a script — useful when the user wants to work outside the app, integrate the model into a larger MATLAB workflow, version-control the training code, or automate/schedule the workflow. Use the app.generateCode() variant when the code is needed as a string. Produces a .m training function covering data preprocessing (feature selection, PCA), model training, and validation. Works for all model types. Note: re-running the generated script may not exactly reproduce the app's results due to randomization in cvpartition.app.exportPlotData('VariableName', 'myPlot') to export the current active plot's data to the workspace for further analysis. Use app.exportPlotToFigure() to export the active plot to a standalone MATLAB figure (for saving as an image or customizing). Use app.exportResultsTableToWorkspace('VariableName', 'myResults') or app.exportResultsTableToFile('results.csv') to export the Results Table (visible rows and columns only) to the workspace or a CSV file. These are useful when the user wants to share results, create custom visualizations, or integrate findings into reports. For full export method signatures and parameters, see references/api-export-and-diagnostics.md#programmatic-export-methods.app.exportModelToWorkspace('MyModel') (optionally 'IncludeTrainingData', false for a compact export). What gets exported (all paths): a full model trained on the entire training set (not a CV-fold model), so the exported artifact is always a fresh fit on all available training data.app.exportModelToSimulink(...). Categorical predictors are NOT supported — warn early. For full constraint list and supported model types, see references/skill-guidance-details.md#export-to-simulink-r2024a. For exportModelToSimulink parameter table, see references/api-export-and-diagnostics.md#export-model-to-simulink-r2024a.app.exportModelToCoder(...). For constraint list and sizing guidance, see references/skill-guidance-details.md#export-to-coder-r2025a. For exportModelToCoder parameter table, see references/api-export-and-diagnostics.md#export-model-to-coder-r2025a.app.createExperiment(...). Model must be trained first. For decision logic (when to use vs. app-level optimization, when to skip the Learner app), see references/skill-guidance-details.md#export-to-experiment-manager-r2022a.app.clickExportModelToProductionServerToolstripButton(). Requires MATLAB Compiler SDK. See references/skill-guidance-details.md#export-to-production-server.Features have minimum MATLAB release constraints. Calling a feature on an older release will error.
| Feature | Minimum Release |
|---|---|
| Set optimizer options | R2019b |
| Set cost matrix | R2019b |
| Export to Production Server, Optimizable Neural Network models, Classification Kernel models | R2021b |
| Save/load session to file, Feature ranking, Regression Kernel models | R2022a |
| Results table, Partial dependence plot | R2022b |
| Create experiment (Experiment Manager), Save compact session to file, Efficient Linear classification models (LogisticRegression, LinearSVM, All) | R2023a |
| Local Shapley, LIME, Efficient Linear regression models (LS, SVM, All), Optimizable Efficient Linear, Optimizable Kernel | R2023b |
| Export model to Simulink, Simulink multi-train presets (AllSimulink), Neural Network models (Uni/Bi/Tri-Layered, All) | R2024a |
| Shapley importance/summary/dependence plots, Compare results plot, Precision-Recall plot, Export plot data, Additional metrics (Precision, Recall, F1-Score) | R2024b |
| Export model to Coder, Codegen multi-train presets (AllCodegen), Permutation importance plot, Compare ROC Curves plot | R2025a |
| Import trained model from workspace | R2026a |
| Deep Learning models (FullyConnected, Residual, All), Training progress plot, Network analyzer plot, Export partitions and data sets | R2026a |
% 1. Open app with data
% Classification:
app = mlearnapp.internal.appcontroller.AppController.openApp('classification', Tbl, 'Response', 'KFold', 5);
% Regression:
% app = mlearnapp.internal.appcontroller.AppController.openApp('regression', Tbl, 'Price', 'KFold', 5);
% 2. Discover available model types and create models
% IMPORTANT: Always call getAvailableModelTypes to discover exact enum names.
% Do NOT guess enum names — they vary by category and release.
% Example: Naive Bayes is 'ClassificationGaussianNaiveBayes', not 'ClassificationNaiveBayes'
available = app.getAvailableModelTypes(); % all valid for this release
% 'Category' is a case-insensitive substring filter on the enum name
% (e.g., 'Tree', 'SVM', 'Ensemble', 'KNN', 'NeuralNetwork', 'Linear', 'Kernel', 'AllSimulink', ...).
% Call getAvailableModelTypes() with no filter first if unsure which substring will match.
treeModels = app.getAvailableModelTypes('Category', 'Tree');
% For guidance on picking an All-* preset family (AllQuickToTrain vs full All vs
% family-specific like AllTrees, AllSVM, AllEnsemble, AllLinear, AllKernel, etc.),
% see references/skill-guidance-details.md#multi-train-presets-all----which-to-pick
% For model type enum names, see references/api-session-and-models.md#gallerymodels-enum-reference
app.createModelType('ClassificationAllQuickToTrain');
% 2b. (Optional) Set hyperparameters on a DRAFT model BEFORE training
% Signature: app.setModelHyperparameterOptions(modelNumber, 'Param', value, ...)
% The first argument MUST be the model number string (e.g., '2', '3.1')
app.setModelHyperparameterOptions('2', 'BoxConstraint', 10, 'KernelScale', 2);
% 3. Train and wait
app.clickTrainToolstripButton();
app.waitForTrainingToComplete();
% 4. Compare models
app.clickResultsTableToolstripButton();
app.openCompareResultsPlot();
allMetrics = app.getAllModelMetrics();
% 5. Select best model (use model number from allMetrics)
% Classification: use AccuracyMetric (or MacroF1ScoreMetric for imbalanced data)
[~, bestIdx] = max([allMetrics.AccuracyMetric]);
% Regression: use RMSEMetric (lower is better) or RSquaredMetric (higher is better)
% [~, bestIdx] = min([allMetrics.RMSEMetric]);
app.selectModelByNumber(allMetrics(bestIdx).ModelNumber);
% 6. Test on held-out data
app.importTestData('testTable');
app.clickTestSelectedModelToolstripButton();
testMetrics = app.getCurrentModelTestDataMetrics();
% 7. Export
app.exportModelToSimulink('MyModel.slx');
% 8. Close app (use 'Force', true ONLY for automated testing — never without user permission)
app.closeApp('Force', true);
Copyright 2026 The MathWorks, Inc.
manifest.yaml (opens in a new tab)references/api-explainability.md (opens in a new tab)references/api-export-and-diagnostics.md (opens in a new tab)references/api-metrics-and-options.md (opens in a new tab)references/api-plots.md (opens in a new tab)references/api-session-and-models.md (opens in a new tab)references/skill-guidance-details.md (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/AlertDialogController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/AppController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/AppControllerBase.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/AutoDismissConfirmDialogController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/CoderExportStubs.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/CustomModelController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ExperimentExportStub.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ExplainPlotController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ExportController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ImportController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ImportTestDataStubView.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/ModelOptionsController.p (opens in a new tab)scripts/+mlearnapp/+internal/+appcontroller/NewSessionDialogController.p (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/ai-and-statistics:matlab-use-machine-learning-appsfrom 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-classify-tabular-dataUse this skill to classify tabular data end-to-end in MATLAB — load a dataset, prepare and clean it, select promising classifiers, train them, and compare accuracies with cross-validation, holdout, or hyperparameter optimization plus statistical tests. TRIGGER when: user asks to classify tabular data, pick classifiers for a dataset, compare the accuracy of several classifiers by cross-validation or holdout, or find the best model with statistical uncertainty. DO NOT TRIGGER when: user has non-tabular inputs (images, sequences, time series), wants a regression model, wants the Classification or Regression Learner app (use matlab-use-machine-learning-apps), evaluates one model already chosen, is training a specific neural network architecture (use matlab-train-network), or wants cost-sensitive learning or an arbitrary class-prior vector (use fitc* with 'Prior' or 'Cost'; this skill only supports the built-in uniform-prior toggle).
/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.
Other plugins' skills for the same job