discretize data to learning naivebayes

The engine.
Post Reply
xchi
Posts: 2
Joined: Thu Jan 09, 2014 10:14 pm

discretize data to learning naivebayes

Post by xchi »

Hi there,

I have discretized my columns of variables (except for the last column, which is already discrete since it is my class variable) from my dataset d.
for example, for the first two columns of d:

floatData = d.GetFloatData(0);
DSL_discretizer disc0 = floatData;
disc0.Discretize(DSL_discretizer::MethodType::UniformCount, 8, be[0]);

floatData = d.GetFloatData(1);
DSL_discretizer disc1(floatData);
disc1.Discretize(DSL_discretizer::MethodType::UniformCount, 8, be[1]);

I would now like to learn a naive bayes net from the discretized data. do i need to somehow write these disc0 and disc1 back into my dataset d?
because when I tried calling,

DSL_network result;
DSL_nb nb;
nb.classVariableId = "Type"; //Type is my class variable in dataset d.
if (nb.Learn(d,result)!=DSL_OKAY)

I get the following error at the last line...

Assertion failed: metadata[var].discrete, file d:\shooltz\dsl\repo\smilearn\dataset.h, line 186.

am I missing a step in between discretization and structural learning?

please advise, thanks!
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: discretize data to learning naivebayes

Post by shooltz[BayesFusion] »

DSL_discretizer::Discretize returns the bin edges which you can manually apply to your continuous data in order to convert it to discrete.
It does not change the actual values in the dataset object.

While it's possible to use DSL_discretizer directly, it's much easier to call DSL_dataset::Discretize instead.
xchi
Posts: 2
Joined: Thu Jan 09, 2014 10:14 pm

Re: discretize data to learning naivebayes

Post by xchi »

thank you so much. I used DSL_dataset::discretize, and it was so much easier!
Post Reply