pysmile k-fold CV

The engine.
Post Reply
liid
Posts: 15
Joined: Tue Jun 19, 2018 5:19 am

pysmile k-fold CV

Post by liid » Sat Aug 04, 2018 6:36 am

Hi,

Just started using pysmile (was using only GeNle so far, but reached to a point where I need some bigger scale network). I have two questions and will be very grateful if you can answer :

1. I am trying to understand how to perform a simple k-fold CV in pysmile. This topic is not included in the wrappers tutorial.
What I need to is pretty much what the following code does, only for pysmile:

DSL_dataset ds;
DSL_network net;
vector<DSL_datasetMatch> matching;
// load network and dataset, create the matching here
DSL_validator validator(ds, net, matching);
int classNodeHandle = net.FindNode("someNodeIdentifier");
validator.AddClassNode(classNodeHandle);
DSL_em em;
// optionally tweak the EM options here
int res = validator.KFold(em, 5);
if (DSL_OKAY == res)
{
double acc;
validator.GetAccuracy(classNodeHandle, 0, acc);
printf("Accuracy=%f\n", acc);
}

Can you please provide a short description about doing CV in pysmile? if not, can you please provide a reference to a document that explains it?

2. I need to create a pretty large cpt (30-50 binary parents) threw pysmile, and I am not sure about the order in which the probabilities should appear in the array. For example, for a ternary node with two binary parents, can you please explain in what order should the 12 probabilities appear?

Thanks a lot!

piotr [BayesFusion]
Site Admin
Posts: 29
Joined: Mon Nov 06, 2017 6:41 pm

Re: pysmile k-fold CV

Post by piotr [BayesFusion] » Tue Aug 07, 2018 7:16 am

1.
I'm assuming, that you initialized dataset and network properly (as ex. ds and net).

Code: Select all

node_id = "someNodeIdentifier"
matching = ds.match_network(net)
validator = pysmile.Validator(net, ds, matching)
validator.add_class_node(node_id)
em = pysmile.Learning.EM()
em.learn(ds, net, matching)
validator.k_fold(em, 5)
acc = validator.get_accuracy(node_id, 0)
print("Accuracy=" + str(acc))
2.
Check out docs page: https://support.bayesfusion.com/docs/
SMILE Programmer's Manual (C++) page 26
SMILE Wrapper Programmer's Manual (Java, Python, .NET) page 35,37

Yang Yajie
Posts: 16
Joined: Thu Mar 19, 2020 11:49 am

Re: pysmile k-fold CV

Post by Yang Yajie » Mon Jul 20, 2020 6:36 pm

i modify my code, but i get the results "Accuracy=nan". What is the "nan" mean? (the ...2659.png shows the results)what kind of results represent the network is good after the validation? My file.xdsl is a DBN network.
besides that, i use my another nodes like "Marriage_status", I get the errno=-30 (the ...3447.png shows the results). Could you please tell me why? Did i do something wrong?
Attachments
WeChat Image_20200720203447.png
WeChat Image_20200720203447.png (195.96 KiB) Viewed 1205 times
WeChat Image_20200720202659.png
WeChat Image_20200720202659.png (147.24 KiB) Viewed 1205 times

shooltz[BayesFusion]
Site Admin
Posts: 1269
Joined: Mon Nov 26, 2007 5:51 pm

Re: pysmile k-fold CV

Post by shooltz[BayesFusion] » Mon Jul 20, 2020 9:26 pm

SMILE does not support validation (including k-fold) in DBNs. You need to unroll your network and run k-fold on the non-DBN model.

Yang Yajie
Posts: 16
Joined: Thu Mar 19, 2020 11:49 am

Re: pysmile k-fold CV

Post by Yang Yajie » Wed Jul 22, 2020 8:45 am

i make a simple BBN network, the network type as shown in picture 4314.png. and use the corresponding data, as shown in aa.csv. but the resutls is "nan". could you please tell me why? and what kind of results represent the network is good after validation?
Attachments
WeChat Image_20200722104314.png
WeChat Image_20200722104314.png (34.23 KiB) Viewed 1186 times
validatorWeChat Image_20200722103759.png
validatorWeChat Image_20200722103759.png (110.8 KiB) Viewed 1186 times
aa.csv
(381 Bytes) Downloaded 41 times

shooltz[BayesFusion]
Site Admin
Posts: 1269
Joined: Mon Nov 26, 2007 5:51 pm

Re: pysmile k-fold CV

Post by shooltz[BayesFusion] » Thu Jul 23, 2020 1:39 pm

Can you share your "validator test.xdsl" file so we can reproduce the problem?

Post Reply