designecoc
statistics: M = designecoc (K, name)
statistics: M = designecoc (…, 'NumTrials', n)
Coding design matrix for an error correcting output codes model.
M = designecoc (K, name) returns the coding design
for K classes named by name. M is a KxL matrix of
-1, 0 and +1 with one row per class and one column per binary learner: a
learner is trained to tell the classes marked +1 in its column from those
marked -1, and a class marked 0 takes no part in it.
K must be an integer of at least 2. name must be one of:
| Design | Columns | Description |
|---|---|---|
'onevsone' | K(K-1)/2 | One column per pair of classes, the earlier class +1 and the later -1, pairs taken in order. |
'onevsall' | K | One column per class, that class +1 and every other -1. |
'binarycomplete' | 2^(K-1)-1 | Every way of splitting the classes into two non-empty groups, with the first class always +1. |
'ternarycomplete' | (3^K-2^(K+1)+1)/2 | Every way of splitting into two non-empty groups while leaving any classes out. It grows fast: 28501 columns at K = 10. |
'ordinal' | K-1 | Column j separates the first j classes from the rest, for classes that are ordered. |
'denserandom' | about 10log_2 K | Random -1 and +1, no class left out. |
'sparserandom' | about 15log_2 K | Random -1, 0 and +1, a class left out of a column with probability 0.5. |
Source Code: designecoc
M = designecoc (…, draws
n random designs and keeps the one whose rows are furthest apart,
which is what makes a random design correct errors. The default is 10000.
It is accepted but does nothing for the five designs that are not random.
'NumTrials', n)
K = 2 gives the single column [-1; 1] whatever the design,
there being only one way to tell two classes apart.
The two random designs cannot be reproduced from MATLAB and neither can
their width. Measured on R2024a: five runs at K = 10 gave
'denserandom' 38, 38, 38, 40 and 40 columns and
'sparserandom' 57, 55, 55 and 54, so the number of columns varies
between runs of MATLAB itself. The five other designs are exact.
See also: fitcecoc, ClassificationECOC
Source Code: designecoc