 |
|
| Computers Forum Index » Computer Artificial Intelligence - Neural Nets » Matlab and BN Toolbox issue... |
|
Page 1 of 1 |
|
| Author |
Message |
| Stefio... |
Posted: Wed Oct 21, 2009 3:08 pm |
|
|
|
Guest
|
Hello,
I have just started to study BN in order to classify some data in 2
different classes. I am using Matlab and the BN Toolbox. I've managed
to build a network and estimate the probability distributions for each
node, and run the classifier. My first network is a simple 3 nodes
network, node1 is a discrete parent (i.e. class1=1 class1=0) and the
other two are children with a gaussian distribution (based on a
normfit on 2 variables from my data). The classifier works pretty
good, even if it's just a raw simple one.
Now, I want know to go deeper into the relations in my data, and so I
want to try to learn the network structure from the data. The data
matrix has in its first column the class of the cases (0 or 1, so I
had to add 1 because it said me "??? Subscript indices must either be
real positive integers or logicals."). Anyway, I've tried
clear all
dags = mk_all_dags(3);
load data;
A = [data(:,1)+1';data(:,9)';data(:,2)'];
node_sizes = [2 1 1];
score = score_dags(A,node_sizes,dags, 'discrete', 1, 'scoring_fn',
'bic', 'params', [], 'type', {'tabular', 'gaussian', 'gaussian'});
The answer is always
"??? Error using ==> vertcat
CAT arguments dimensions are not consistent."
So I've tried this, just to see if it works:
dags = mk_all_dags(2);
node_sizes = [2 1];
A = [1 1 2 2 1 1; 2 2 1 1 2 2];
score = score_dags(A,node_sizes,dags, 'discrete', 1, 'scoring_fn',
'bic', 'params', [], 'type', {'tabular', 'gaussian'});
which works actually.. but if I put in a column of A matrix values
higher than 2, for istance using
A = [1 1 2 2 1 1; 2 2 1 2 2 2];
it gives me
"??? Index exceeds matrix dimensions.".
So I don't know what to try, and why my first example doesn't work. I
guess I should tell him something more about the distribution in order
to learn the structure, but adding just parameters as in the node
constructor it doesn't work. There aren't many explanation on the
internet about using this exaustive search for structures with
gaussian distributions. Do you know how should I proceed or
investigate?
Thank you
Stefio |
|
|
| Back to top |
|
|
|
| Stefio... |
Posted: Wed Oct 21, 2009 3:24 pm |
|
|
|
Guest
|
On Oct 21, 4:08 pm, Stefio <ste... at (no spam) email.it> wrote:
Quote: Hello,
I have just started to study BN in order to classify some data in 2
different classes. I am using Matlab and the BN Toolbox. I've managed
to build a network and estimate the probability distributions for each
node, and run the classifier. My first network is a simple 3 nodes
network, node1 is a discrete parent (i.e. class1=1 class1=0) and the
other two are children with a gaussian distribution (based on a
normfit on 2 variables from my data). The classifier works pretty
good, even if it's just a raw simple one.
Now, I want know to go deeper into the relations in my data, and so I
want to try to learn the network structure from the data. The data
matrix has in its first column the class of the cases (0 or 1, so I
had to add 1 because it said me "??? Subscript indices must either be
real positive integers or logicals."). Anyway, I've tried
clear all
dags = mk_all_dags(3);
load data;
A = [data(:,1)+1';data(:,9)';data(:,2)'];
node_sizes = [2 1 1];
score = score_dags(A,node_sizes,dags, 'discrete', 1, 'scoring_fn',
'bic', 'params', [], 'type', {'tabular', 'gaussian', 'gaussian'});
The answer is always
"??? Error using ==> vertcat
CAT arguments dimensions are not consistent."
So I've tried this, just to see if it works:
dags = mk_all_dags(2);
node_sizes = [2 1];
A = [1 1 2 2 1 1; 2 2 1 1 2 2];
score = score_dags(A,node_sizes,dags, 'discrete', 1, 'scoring_fn',
'bic', 'params', [], 'type', {'tabular', 'gaussian'});
which works actually.. but if I put in a column of A matrix values
higher than 2, for istance using
A = [1 1 2 2 1 1; 2 2 1 2 2 2];
it gives me
"??? Index exceeds matrix dimensions.".
So I don't know what to try, and why my first example doesn't work. I
guess I should tell him something more about the distribution in order
to learn the structure, but adding just parameters as in the node
constructor it doesn't work. There aren't many explanation on the
internet about using this exaustive search for structures with
gaussian distributions. Do you know how should I proceed or
investigate?
Thank you
Stefio
I have a correction to make, the first error
"??? Error using ==> vertcat
CAT arguments dimensions are not consistent."
was just due the A matrix, which must be built like
A = [data(:,1)'+1;data(:,9)';data(:,2)'];
In this case the error is
"??? Subscript indices must either be real positive integers or
logicals."
and this error is in this command: p = CPT(indices).
I've tried to modify the function in order to print the "indices"
variable, and it shows me that indices are first a series of 1 and 2
(which is correct), and then even the other columns (a series of
gaussian distributed values). I am still confused. |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Tue Dec 08, 2009 4:55 pm
|
|