daugsbi / randomforest-matlab

Automatically exported from code.google.com/p/randomforest-matlab
0 stars 0 forks source link

Incorrect relabeling of training set caused crash (Bugs in r54) #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A. What steps will reproduce the problem?
1. Use RF to perform a classification task. We run the training program.
2. For training set, the labeling is [0,2]
3. We do not specify testing data when perform training.

B. What is the expected output? What do you see instead?
Expected successful training.
However. current version contains a bug causing crash.

C. What version of the product are you using? On what operating system?
R54. On Windows 8.

D. Possible cause is because of the following relabeling in classRF_train.m:

if exist('Xtst','var') && exist('Ytst','var') 
        if(size(Xtst,1)~=length(Ytst))
            error('Size of Xtst and Ytst dont match');
        end
        fprintf('Test data available\n');
        tst_available=1;
        tst_size = length(Ytst);
    else
        Xtst=1;
        Ytst=1;
        tst_available=0;
        tst_size=0;
    end

    TRUE=1;
    FALSE=0;

    orig_labels = sort(unique([Y; Ytst]));
    Y_new = Y;
    Y_new_tst = Ytst;
    new_labels = 1:length(orig_labels);

    for i=1:length(orig_labels)
        Y_new(find(Y==orig_labels(i)))=Inf;
        Y_new(isinf(Y_new))=new_labels(i);

        Y_new_tst(find(Ytst==orig_labels(i)))=Inf;
        Y_new_tst(isinf(Y_new_tst))=new_labels(i);
    end

    Y = Y_new;
    Ytst = Y_new_tst;

When running the code using above input:
orig_labels=[0 1 2] and unique(Y_new)=[1 3];

However. after relabeling unique(Y_new) shall become [1 2].

E. Correction is:
Change the line:
  Xtst=1;
  Ytst=1;
into:
  Xtst=X(1,:);
  Ytst=Y(1);

Again. Thanks for the wonderful software!

Original issue reported on code.google.com by KangD...@gmail.com on 18 Sep 2012 at 8:06

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r55.

Original comment by abhirana on 18 Sep 2012 at 5:47

GoogleCodeExporter commented 8 years ago
Thanks a lot!

yup, that xtst condition never occurred to me. fixed it in the repository.

thanks again

regards
abhi

Original comment by abhirana on 18 Sep 2012 at 5:49

GoogleCodeExporter commented 8 years ago
Thanks for the fast reply!

Yours, Dang Kang

Original comment by KangD...@gmail.com on 19 Sep 2012 at 2:59