Ejemplo n.º 1
0
BayesNet *SimpleCondSoftMaxModel()
{ 
    BayesNet *net;
    net = new BayesNet();
    
    net->AddNode("continuous^node0");
    net->AddNode("continuous^node1");
    net->AddNode("continuous^node2");
    net->AddNode("discrete^node3", "True False"); 

    net->AddNode("discrete^node5", "True False");// condsoftmax node
    net->AddNode("discrete^node6", "True False");

    net->AddArc("node0", "node5");
    net->AddArc("node1", "node5");
    net->AddArc("node2", "node5");
    net->AddArc("node3", "node5");
    net->AddArc("node5", "node6");

    net->SetPGaussian("node0", "0.1", "0.9");
    net->SetPGaussian("node1", "0.2", "0.8");
    net->SetPGaussian("node2", "0.3", "0.7");
  
    net->SetPTabular("node6^True node6^False", "0.3 0.7", "node5^True");
    net->SetPTabular("node6^True node6^False", "0.5 0.5", "node5^False");

    net->SetPSoftMax("node5^True node5^False", "0.3 0.4 0.5 0.6 0.7 0.8", "0.1 0.1", "node3^True");
    net->SetPSoftMax("node5^True node5^False", "0.23 0.24 0.25 0.26 0.27 0.28", "0.21 0.21", "node3^False");

    return net;
}
Ejemplo n.º 2
0
BayesNet *SevenNodesModel()
{ 
    BayesNet *net;
    net = new BayesNet();
    
    net->AddNode(continuous^"node0 node1 node5");
    net->AddNode(discrete^"node2 node3 node4 node6", "False True");

    net->AddArc("node0", "node3");
    net->AddArc("node1", "node3");
    net->AddArc("node2", "node3");
    net->AddArc("node3", "node4");
    net->AddArc("node3", "node5");
    net->AddArc("node0", "node6");
    net->AddArc("node4", "node6");
  
    net->SetPGaussian("node0", "0.5", "1.0");
    
    net->SetPGaussian("node1", "0.5", "1.0");
    
    net->SetPTabular("node2^True node2^False", "0.3 0.7");
    
    net->SetPSoftMax("node3^True node3^False", "0.5 0.4 0.5 0.7", "0.3 0.5", "node2^False");
    net->SetPSoftMax("node3^True node3^False", "0.5 0.1 0.5 0.7", "0.3 0.5 ", "node2^True");

    net->SetPTabular("node4^True node4^False", "0.8 0.2", "node3^True");
    net->SetPTabular("node4^True node4^False", "0.3 0.7", "node3^False");

    net->SetPGaussian("node5", "0.5", "0.5", "1.0", "node3^True");
    net->SetPGaussian("node5", "1.0", "1.0", "1.0", "node3^False");

    net->SetPSoftMax("node6^True node6^False", "0.8 0.2", "0.1 0.9", "node4^True");
    net->SetPSoftMax("node6^True node6^False", "0.5 0.9", "0.7 0.3", "node4^False");

    return net;
}
Ejemplo n.º 3
0
BayesNet *SimpleSoftMaxModel()
{ 
    BayesNet *net;
    net = new BayesNet();
    
    net->AddNode(continuous^"node0 node1 node2");
    net->AddNode(discrete^"node5", "True False");

    net->AddArc("node0", "node5");
    net->AddArc("node1", "node5");
    net->AddArc("node2", "node5");
  
    net->SetPGaussian("node0", "0.1", "0.9");
    net->SetPGaussian("node1", "0.2", "0.8");
    net->SetPGaussian("node2", "0.3", "0.7");

    net->SetPSoftMax("node5^True node5^False", "0.3 0.4 0.5 0.6 0.7 0.8", "0.1 0.1");
    return net;
}
Ejemplo n.º 4
0
BayesNet* CropModel()
{
    //  Subsidy(d) Crop(c)
    //          |   |
    //          V   V
    //         Price(c)
    //            |
    //            V
    //          Buy(d)

    BayesNet *net;
    net = new BayesNet();

    textcolor(WHITE);

    net->AddNode(discrete^"Subsidy", "Yes No");
    printf("\n net->AddNode(discrete^\"Subsidy\", \"Yes No\");");
    textcolor(LIGHTGREEN);

    printf("\t\t\t\t\t\tAdding of nodes is in process....");
    _sleep(2000);
    textcolor(WHITE);

    net->AddNode(continuous ^ "Crop");
    printf("\n net->AddNode(continuous ^ \"Crop\");");
    _sleep(1000);

    net->AddNode(continuous ^ "Price");
    printf("\n net->AddNode(continuous ^ \"Price\");");
    _sleep(1000);

    net->AddNode(discrete^"Buy", "Yes No");
    printf("\n net->AddNode(discrete^\"Buy\", \"Yes No\");");

    textcolor(LIGHTGREEN);
    printf("\n ......All nodes are added....\n");
    getch();

    // arcs
    textcolor(WHITE);

    net->AddArc("Subsidy Crop", "Price");
    printf("\n net->AddArc(\"Subsidy Crop\", \"Price\");");
    textcolor(LIGHTGREEN);
    printf("\t\t\t\t\t\t\tAdding of arcs is in process....");
    _sleep(2000);

    textcolor(WHITE);
    net->AddArc("Price", "Buy");
    printf("\n net->AddArc(\"Price\", \"Buy\");");
    textcolor(LIGHTGREEN);
    printf("\n ......All arcs are added....\n");
    getch();

    // distributions
    textcolor(WHITE);

    net->SetPTabular("Subsidy^Yes Subsidy^No", "0.3 0.7");
    printf("\n net->SetPTabular(\"Subsidy^Yes Subsidy^No\", \"0.3 0.7\");");
    textcolor(LIGHTGREEN);
    printf("\t\t\t\t\tAdding of distributions is in process....");
    _sleep(2000);

    textcolor(WHITE);

    net->SetPGaussian("Crop", "5.0", "1.0");
    printf("\n net->SetPGaussian(\"Crop\", \"5.0\", \"1.0\");");
    _sleep(1000);

    net->SetPGaussian("Price", "10.0", "1.0", "-1.0", "Subsidy^Yes");
    printf("\n net->SetPGaussian(\"Price\", \"10.0\", \"1.0\", \"-1.0\", \"Subsidy^Yes\");");
    _sleep(1000);

    net->SetPGaussian("Price", "20.0", "1.0", "-1.0", "Subsidy^No");
    printf("\n net->SetPGaussian(\"Price\", \"20.0\", \"1.0\", \"-1.0\", \"Subsidy^No\");");
    _sleep(1000);

    net->SetPSoftMax("Buy^Yes Buy^No", "-1.0 1.0", "5.0 -5.0");
    printf("\n net->SetPSoftMax(\"Buy^Yes Buy^No\", \"-1.0 1.0\", \"5.0 -5.0\");");

    textcolor(LIGHTGREEN);
    printf("\n ......All distributions are added....\n");
    getch();
    textcolor(WHITE);

    return net;
}