matlab/matlab-agentic-toolkit / skills-catalog/ai-and-statistics/matlab-engineer-tabular-features
matlab-engineer-tabular-features
UnverifiedUse 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.
scripts/stratifiedDownsampleRows.m
View on GitHubfunction KeepIdx = stratifiedDownsampleRows(Response, MaxRows)
%stratifiedDownsampleRows Row indices capping a table at MaxRows, class-balanced.
%
% KeepIdx = stratifiedDownsampleRows(Response, MaxRows) returns a sorted column
% vector of row indices that trims a table down to at most MaxRows while
% preserving class proportions. When numel(Response) <= MaxRows every row is
% kept (KeepIdx = (1:n)'). This bounds the cost of a stability read on large
% data: the read draws M subsamples and re-runs selection (or generation) on
% each, so the per-resample table size -- not the full dataset size -- sets the
% cost. Capping once here keeps every subsample small without the caller
% re-implementing a stratified trim.
%
% The cap is applied ONCE, up front, before any resampling; the M subsamples
% are then drawn from the capped set (stratifiedSubsampleIndices), so the whole
% stability read operates on <= MaxRows rows.
%
% STRATIFICATION. For a categorical / logical / string response the trim keeps
% round(MaxRows * classShare) rows per class (via cvpartition Holdout), so the
% imbalance ratio is preserved -- essential, since stability on imbalanced data
% is exactly where an accidental class starve would corrupt the read. A
% continuous (regression) response is trimmed by a plain random draw.
%
% Inputs:
% Response - (n,1) response vector; its TYPE decides stratification
% MaxRows - (1,1) positive integer row cap (default 3000)
%
% Output:
% KeepIdx - (:,1) sorted row indices to keep (all rows when n <= MaxRows)
% Copyright 2026 The MathWorks, Inc.
arguments
Response (:,1) {mustBeVector}
MaxRows (1,1) double {mustBePositive, mustBeInteger} = 3000
end
n = numel(Response);
if n <= MaxRows
KeepIdx = (1:n)';
return;
end
Stratify = iscategorical(Response) || islogical(Response) ...
|| isstring(Response) || iscellstr(Response);
if Stratify
% Keep a stratified MaxRows/n fraction: cvpartition's training side
% preserves class proportions.
Part = cvpartition(Response, Holdout = 1 - MaxRows / n);
KeepIdx = find(training(Part));
else
KeepIdx = sort(randperm(n, MaxRows))';
end
end
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 467k | Updated | Claude CodeCodex | Verified | Install |
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 467k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |