forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 2:43 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Problem with random forest
PostPosted: Wed Jan 03, 2018 1:07 pm 
Offline

Joined: Wed Jan 03, 2018 1:05 pm
Posts: 2
Hello!
I get problem with using random forest methods

Here is building RF
Code:
  double[,] xy = new double[,]
  {{0, 0, 0, 0, 0, 255, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0, 1},
  {0, 255, 0, 0, 0, 0, 0, 0, 2},
  {0, 0, 0, 0, 255, 0, 0, 0, 3},
  {0, 0, 0, 0, 0, 0, 0, 255, 4}};
  alglib.dfbuildrandomdecisionforestx1(xy, 8, 5, 5, 50, 3, 0.6, out info, out df, out rep);


When I try to use it like this
Code:
double[] x = new double[]{0, 0, 0, 0, 0, 0, 0, 0};
  alglib.dfprocess(df, x, ref y);

I get wrong classification result {0.005, 0.49, 0, 0.505, 0}. So max possibility is 4th value (0.505). But it should be 2nd value (inner value is zero array, that is class 1)
Please help me to solve this problem.
Thank you!


Top
 Profile  
 
 Post subject: Re: Problem with random forest
PostPosted: Wed Jan 03, 2018 4:59 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Hi!

Random forests are (no surprise!) randomized constructs. They try randomly many different classification schemes, with different variables being selected - and different random datasets being generated for training. In particular, it is very likely that roughly 40% of your random trees will be trained without instances of class #2. And your toy dataset is not well suited for randomized methods - drop just one variable (say, last one), and you can not reliably distinguish between instances of classes #2 and #4.

So, it is completely normal that on such small toy dataset you get such results. Try training on larger dataset, with noise being added to inputs.


Top
 Profile  
 
 Post subject: Re: Problem with random forest
PostPosted: Thu Jan 04, 2018 5:28 am 
Offline

Joined: Wed Jan 03, 2018 1:05 pm
Posts: 2
Thank you for reply and your advise!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group