Thanks for using this code. This code contains experiments to test maximum-margin output coding for multi-label classification.


0. Reference
Yi Zhang and Jeff Schneider. Maximum Margin Output Coding, ICML 2012.


1. External software
Note that you need to install Liblinear package (http://www.csie.ntu.edu.tw/~cjlin/liblinear/) and cvx (http://cvxr.com/cvx/download/) before you can run this code. I include a linux compiled file for liblinear, but you probably need to compile your own version.


2. Launch the experiments
Use test_Medical_MultiLabel.m, test_Scene_MultiLabel.m and test_Emotion_MultiLabel.m to launch experiments, e.g, test_Scene_MultiLabel(300,30) for 30 random runs and 300 training samplea in each run.


3. Test your own data
If you have your own data, you need to prepare your data file and write a wrapper similarly as test_Scene_MultiLabel.m.

The data file needs to at least contain: trX (nTrain * nFeature), trY (nTrain * nLabel), tsX (nTest * nFeature), tsY (nTest * nLabel), indicies (nRun * 1 cell array, where each cell contains an 1 * nTrain permutation vector)

As test_Scene_MultiLabel.m, your wrapper will call a function IOCoding_MultiLabel_TrainTest_OC_Greedy(). See comments in the IOCoding_MultiLabel_TrainTest_OC_Greedy.m file for the parameter settings.


4. Read the results
The code will write all results into a file, e.g., file_Scene_nSample300_MaxMarginCoding_MFADecodingCorrected.mat.

In the file, you will see several result arrays for subset accuracy, micro F1 and macro F1 scores.

Take subset accuracy for example, you will see three arrays: SubAccuracy, SubAccuracy_2, SubAccruacy_3. They corresponds to three different values for \lambda in the decoding equation (15) in the ICML 2012 paper: 1/4, 1, 4. If you don't want to tune this decoding parameter, then you can just look at SubAccuracy_2 (or microF1_2, macroF1_2), which corresponds to \lambda = 1 in decoding eq.(15).

Take the array SubAccuracy_2 for example, each row is for a random run, and each column corresponds to a specific number of label projections used by the coding. The number of projections is stored in the variable nComps (i.e., nComps has the same number of columns as each result array, and each element of nComps tells the number of label projections used in each column of the result array). If you don't want to tune this parameter (as in our paper), you can just look at the last column of SubAccuracy_2 (or microF1_2, macroF1_2), which corresponds to using the max number of label projections.

Now, take a column of a result array, you have the result for all random runs, each row is for one random run.


5. Alternative method
We have also proposed a CCA-based coding (Yi Zhang and Jeff Schneider. Multi-label Output Codes using Canonical Correlation Analysis, AISTATS 2011), which is simpler, computationally more efficient, and usually performs nearly as good as this max-margin coding.

Both the paper and its code can be found at http://www.cs.cmu.edu/~yizhang1


6. Contact
Yi Zhang, yizhang1@cs.cmu.edu

