33%! Region = [repmat({"North"}, 20, 1); repmat({"South"}, 15, 1); repmat({"East"}, 15, 1); repmat({"West"}, 20, 1)];
44%!
55%! Success = [repmat({"Success"}, 49, 1); repmat({"Fail"}, 21, 1)];
6- %! Success = Success(randperm(70));
6+ %! Success = Success(randperm (70));
77%!
8- %! Tbl = table(Region, Success);
8+ %! Tbl = table (Region, Success);
99%!
1010%! ## Grouped K-Fold Partition (GroupingVariables = Region)
11- %! c_group = cvpartition(height(Tbl), 'KFold', 4, 'GroupingVariables', Tbl.Region);
12- %! summaryGroup = summary(c_group)
11+ %! c_group = cvpartition (height (Tbl), 'KFold', 4, 'GroupingVariables', Tbl.Region);
12+ %! summaryGroup = summary (c_group)
1313
1414%!demo
1515%! ## Stratified K-Fold Partition (Stratification Variable = Success)
16- %! c_strat = cvpartition(Tbl.Success, 'KFold', 5);
17- %! summaryStrat = summary(c_strat)
16+ %! c_strat = cvpartition (Tbl.Success, 'KFold', 5);
17+ %! summaryStrat = summary (c_strat)
1818
1919%!demo
2020%! ## Filtering by Exact Set Name ('test1')
2121%! ## (Uses summaryStrat from the previous block)
22- %! summaryTest1 = summaryStrat(strcmp(cellstr( summaryStrat.Set) , "test1"), :)
22+ %! summaryTest1 = summaryStrat (strcmp ( summaryStrat.Set, "test1"), :)
2323
2424%!demo
2525%! ## Filtering by Partial Match (equivalent to 'contains("test")')
26- %! is_test = ~ cellfun('isempty', strfind(cellstr(summaryStrat.Set), "test"));
27- %! testSummaryTbl = summaryStrat(is_test, :)
26+ %! is_test = ! cellfun ('isempty', strfind (cellstr (summaryStrat.Set), "test"));
27+ %! testSummaryTbl = summaryStrat (is_test, :)
2828
2929%!demo
3030%! ## Unstacking (Pivoting) the Stratified Table
3131%!
3232%! ## Unstack: Pivot 'StratificationLabel' (Success/Fail) into new columns,
33- %! speciesSummaryTbl = unstack(summaryStrat(:,1:4), "StratificationCount", "StratificationLabel")
33+ %! ## using 'StratificationCount' as values.
34+ %! speciesSummaryTbl = unstack (summaryStrat (:, 1:4), "StratificationCount", "StratificationLabel")
0 commit comments