Author Topic: Importing and Exporting CPTs  (Read 21352 times)

Offline QC88

  • Newbie
  • *
  • Posts: 3
    • View Profile
Importing and Exporting CPTs
« on: September 25, 2012, 20:04:42 »
Hi everyone, Hugin newbie here. I am trying to save the CPTs generated by Hugin to a file so that I don't have to generate them everytime I start the program and want to do inference. The problem is, when I try to export the CPTs by either going to file -> print node tables or functions -> export table, it will only export the name of the node and the functional relationship. It does not write the actual entries of the CPT for a child node to the file. Does anyone know what I am missing?

Offline Martin

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 613
    • View Profile
Re: Importing and Exporting CPTs
« Reply #1 on: September 27, 2012, 15:20:56 »
Hello.

I am not sure exactly what you mean.

If you are using expressions, then HUGIN automatically generates the tables when switching to run mode - there are no extra manual steps needed to do inference.

To export a CPT to text file. In edit mode press and hold CTRL and then click the node to open the CPT.
In the table window select Functions->Export Table to export the table to a text file.
If the table has an expression only the expression is written to the text file.

But why export and import tables each time you start HUGIN?
It is better to just save the net file (click File->Save As) and load it next time you start HUGIN.
Hugin Expert A/S

Offline QC88

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Importing and Exporting CPTs
« Reply #2 on: September 27, 2012, 20:02:16 »
I was not aware that the tables were generated automatically when switching to run mode. Thanks for clearing that up for me.

My reasoning is that it takes a while (>20 min) to determine all of the CPTs for my network, and I don't want to have to wait each time I open the program and want to do inference. That's why it would be great if I could just run the CPT generator once, and then import them all from a file and jump right to the inference from then on. Is there a way to do this?

Offline Martin

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 613
    • View Profile
Re: Importing and Exporting CPTs
« Reply #3 on: October 01, 2012, 15:44:20 »
Generating tables from expressions should not take that long.

I suspect that the >20 min wait you experience is spent on triangulating the network when switching to run-mode.

You could try experimenting with the triangulation options (Click Network -> Network Properties, switch to compilation tab).

Specifically you could try saving and re-using the triangulation:
Step 1: switc to run-mode (and do the >20 min wait)
Step 2: then save the triangualtion - click Network -> Save Elimination Order
Step 3:-Finally in Network Properties, compilation tab - configure triangulation method to be the "load triangulation" option - and save the network.

Next time you load the network in HUGIN and switch to run-mode, load the triangulation when prompted and see if the wait is shorter.
Hugin Expert A/S

Offline QC88

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Importing and Exporting CPTs
« Reply #4 on: October 02, 2012, 05:39:24 »
I tried that and it did not seem to affect the computation time.

However, it seems that if I go through in edit mode and determine the CPTs for each node individually, Hugin will save the CPTs. This makes the network a massive file, which I'm ok with.

So I guess the thing to do with large networks is to suffer through computation time once, and allow Hugin to save the CPTs in the model file.