When you ask for an OOB margin from one tree, you get zero if this observation was in bag for this tree. The margin is undefined in this case, and TreeBagger returns 0 by default. The cumulative calculation averages over trees for which this observation was out of bag only. Check this out:
>> load fisheriris
>> b = TreeBagger(10,meas,species,'oobpred','on');
>> mi = oobMargin(b,'mode','individual');
>> mi(1,:)
ans = 1 0 0 0 1 0 1 1 0 0
>> b.OOBIndices(1,:)
ans = 1 0 0 0 1 0 1 1 0 0
>> mc = oobMargin(b,'mode','cumulative');
>> mc(1,:)
ans = 1 1 1 1 1 1 1 1 1 1
Best Answer