sambofra / bnstruct

R package for Bayesian Network Structure Learning
GNU General Public License v3.0
17 stars 11 forks source link

hi~ I'm setting my bn and when learning the following error appears. #15

Closed yaowang1111 closed 4 years ago

yaowang1111 commented 4 years ago

I did some googleing but found no helpful information, please help~

... ... ... ... ... ... ... ... bnstruct :: learning the structure using MMHC ... ... ... ... ... ... ... ... ... bnstruct :: learning using MMHC completed. ... ... ... ... ... ... ... ... bnstruct :: learning network parameters ... Error in validObject(x) : invalid class “BN” object: incorrect list of quantiles

albertofranzin commented 4 years ago

Hello,

it means that you specified a bad list of node sizes (second row of header file). Can you provide some additional information?

yaowang1111 commented 4 years ago

the BNdataset code is as follows:

dataset=BNDataset(data=reorganized_data,discreteness=c(TRUE,FALSE,FALSE,TRUE,TRUE,TRUE),node.sizes=c(2,8,8,7,7,4),variables=c('disagreement_trials','correct_percent1','correct_percent2','confidence_response1','confidence_response2','result'))

My _reorganizeddata contains 'correct_percent1','correct_percent2' which are continuous variables whose range are [1.00, 7.75], so i set the node.size to be 7,7, it won't work, then i tried 8,8, still the same error. When i delete these two variables, the code runs fine, i think it might be some problem with my setting continuous variables.

Thanks for the help.

albertofranzin commented 4 years ago

Which version of bnstruct are you using?

What happens if you set the parameter at a lower value?

yaowang1111 commented 4 years ago

I'm using 1.0.6, and when i set the parameter at some lower values, the same error. So i changed the continuous variable to discrete variables at the preprocessing stage, the package work fine.

Now i'm in another trouble. I reshaped my data to be a [num_sample,(num_time_steps by num_variables)]( which is actually[55,240 by 5]) matrix if i understand the tutorial right. Then i try to create my dataset using the following code:

dataset.from.data=BNDataset(data=dbn_data,discreteness=c(TRUE,TRUE,TRUE,TRUE,TRUE),node.sizes=c(2,3,7,7,4),num.time.steps =240,variables=c('disagreement_trials','correct_percent1','confidence_response1','confidence_response2','result'))

The error report is invalid class “BNDataset” object: incoherent number of variable names

Not sure where the problem is. Thanks for the help!

albertofranzin commented 4 years ago

You are doing correctly. It looks like there was a bug when instantiating a BNDataset with multiple time steps directly (without loading the data from a file).

I have fixed it, can you please try with the latest commit?

yaowang1111 commented 4 years ago

The new commit solved my problem. Thanks again!