wzyn20051216/matlab-agent-skills / skills/matlab-signal-vision-ai
matlab-signal-vision-ai
UnverifiedMATLAB workflow for signal processing, DSP, image processing, computer vision, lidar, medical imaging, deep learning, and AI-assisted reproducible experiments. Use for filters, spectrograms, wavelets, object detection, segmentation, classification, training, inference, generated figures, and for verifying signal or vision results — units, windows, Nyquist, filter response, BER/SNR, masks and boxes, IoU/precision/recall/F1, label alignment, transform invertibility, and split leakage.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.5 KB |
| references/signal-measurement-contract.md | markdown | 10.3 KB |
| references/vision-verification-contract.md | markdown | 13.5 KB |
| scripts/mas_ber_check.m | other | 12.6 KB |
| scripts/mas_detect_check.m | other | 21.5 KB |
| scripts/mas_filter_check.m | other | 12.7 KB |
| scripts/mas_image_contract.m | other | 31.4 KB |
| scripts/mas_image_metrics.m | other | 4.5 KB |
| scripts/mas_measure_contract.m | other | 19.8 KB |
| scripts/mas_ofdm_ber.m | other | 6.8 KB |
| scripts/mas_sample_check.m | other | 9.6 KB |
| scripts/mas_seg_check.m | other | 23.0 KB |
| scripts/mas_spectrum_check.m | other | 7.8 KB |
| scripts/mas_split_seed.m | other | 3.6 KB |
| scripts/mas_stat_verdict.m | other | 10.0 KB |
| tests/test_signal_contract.m | other | 21.5 KB |
| tests/test_signal_vision.m | other | 15.8 KB |
| tests/test_stat_decision.m | other | 8.6 KB |
| tests/test_vision_contract.m | other | 35.3 KB |
scripts/mas_split_seed.m
View on GitHubfunction r = mas_split_seed(y, opts)
%MAS_SPLIT_SEED A reproducible train/validation split, with the leakage checked.
%
% r = mas_split_seed(y) % 70/30, stratified, seed 0
% r = mas_split_seed(y, struct('trainFrac',0.8,'seed',7,'stratify',true))
%
% r.trainIdx, r.valIdx, r.seed
% r.classBalance per class: fraction in train vs fraction overall
% r.noOverlap, r.noGap asserted, not assumed
% r.reproducible re-running with the same seed gives the same indices
%
% WHY THIS IS A TOOL AND NOT TWO LINES OF randperm
% Three defects are common and all three produce a number that looks fine:
% 1. the same seed is not reused, so "we validated on 20 %" is not reproducible;
% 2. a row lands in both sets (index arithmetic off by one), inflating validation
% accuracy;
% 3. the class balance silently shifts, so a 50/50 problem is trained on 70/30.
% All three are cheap to check and expensive to discover late, so they are checked
% here and returned as booleans the caller can assert on.
%
% STRATIFICATION
% Per class, take round(trainFrac*n_c) at random. Rounding can make the achieved
% fraction differ from the target by up to 0.5/n_c per class; that is reported in
% classBalance rather than hidden behind a boolean.
if nargin < 2, opts = struct(); end
opts = dflt(opts, struct('trainFrac', 0.7, 'seed', 0, 'stratify', true));
if ~isvector(y), error('mas_split_seed:y', 'y must be a vector of labels'); end
y = y(:);
n = numel(y);
if n < 4, error('mas_split_seed:short', 'need at least 4 samples'); end
if opts.trainFrac <= 0 || opts.trainFrac >= 1
error('mas_split_seed:frac', 'trainFrac must be in (0,1)');
end
rng(opts.seed);
if opts.stratify
cls = unique(y);
tr = [];
bal = struct('class', {}, 'nTotal', {}, 'nTrain', {}, 'fracIn', {});
for k = 1:numel(cls)
idx = find(y == cls(k));
p = randperm(numel(idx));
nTr = round(opts.trainFrac * numel(idx));
if nTr >= numel(idx), nTr = numel(idx) - 1; end % never leave a class empty
if nTr < 1, nTr = 1; end
tr = [tr; idx(p(1:nTr))]; %#ok<AGROW>
bal(end+1) = struct('class', cls(k), 'nTotal', numel(idx), 'nTrain', nTr, ...
'fracIn', nTr/numel(idx)); %#ok<AGROW>
end
else
p = randperm(n);
nTr = round(opts.trainFrac * n);
tr = p(1:nTr);
bal = struct('class', 'all', 'nTotal', n, 'nTrain', nTr, 'fracIn', nTr/n);
end
tr = sort(tr(:));
va = setdiff((1:n).', tr);
noOverlap = isempty(intersect(tr, va));
noGap = numel(tr) + numel(va) == n;
% reproducibility: the same seed must reproduce the split exactly
rng(opts.seed);
if opts.stratify
tr2 = [];
cls = unique(y);
for k = 1:numel(cls)
idx = find(y == cls(k));
p = randperm(numel(idx));
nTr = round(opts.trainFrac * numel(idx));
if nTr >= numel(idx), nTr = numel(idx) - 1; end
if nTr < 1, nTr = 1; end
tr2 = [tr2; idx(p(1:nTr))]; %#ok<AGROW>
end
tr2 = sort(tr2(:));
else
p = randperm(n);
tr2 = sort(p(1:round(opts.trainFrac*n)).');
end
reproducible = isequal(tr, tr2);
r = struct();
r.trainIdx = tr; r.valIdx = va; r.seed = opts.seed;
r.nTrain = numel(tr); r.nVal = numel(va); r.nTotal = n;
r.classBalance = bal;
r.noOverlap = noOverlap; r.noGap = noGap; r.reproducible = reproducible;
r.ok = noOverlap && noGap && reproducible;
r.detail = sprintf('%d/%d split (seed %d), overlap %d, gap %d, reproducible %d', ...
r.nTrain, r.nVal, opts.seed, ~noOverlap, ~noGap, reproducible);
end
% ---------------------------------------------------------------------------
function o = dflt(o, d)
f = fieldnames(d);
for k = 1:numel(f)
if ~isfield(o, f{k}), o.(f{k}) = d.(f{k}); end
end
end
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| planning-and-task-breakdownaddyosmani/agent-skillsBreaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| screenpipethedotmack/claude-memSearch screen and audio history recorded by Screenpipe and optionally save selected context into claude-mem. Use when the user asks to recall desktop activity, a meeting, or something seen in another app through Screenpipe. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| contact-widgetnexu-io/open-designSelf-contained floating chat widget with welcome screen, social links, meeting button, and message input. Single HTML file, zero dependencies. | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |
| meeting-notesnexu-io/open-designMeeting notes page — title bar with attendees, agenda checklist, decisions block, action items table with owners + dates, and a "next meeting" footer. Use when the brief mentions "meeting notes", "minutes", "1:1 notes", "all-hands recap", or "会议纪要". | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |