예제 #1
0
 public static void CreateDistributionsNode(ModelNodeNonShared node, Range N)
 {
     if (node.distributionType == DistributionType.Categorical)
     {
         if (node.parents.Count == 0)
         {
             node.distributions = new NoParentNodeCategoricalNonShared(node);
         }
         else
         {
             int numCategorical = 0;
             foreach (var parent in node.parents)
             {
                 numCategorical += parent.distributionType == DistributionType.Categorical ? 1 : 0;
             }
             if (numCategorical == node.parents.Count)
             {
                 if (node.parents.Count == 1)
                 {
                     node.distributions = new OneCategoricalParentNodeCategoricalNonShared(node);
                 }
                 else if (node.parents.Count == 2)
                 {
                     //   node.distributions = new TwoCategoricalParentNodeCategorical(node);
                 }
                 else if (node.parents.Count == 3)
                 {
                     throw new ArgumentException("Only up to 2 Categorical Parents Allowed");
                     // node.distributions = new ThreeCategoricalParentNodeCategorical(node);
                 }
             }
             else
             {
                 if (numCategorical == 0)
                 {
                     node.distributions = new SoftmaxCategoricalNonShared(node);
                 }
                 else
                 {
                     node.distributions = new SoftmaxCategoricalOneParentNonShared(node);
                 }
             }
         }
     }
     else
     {
         if (node.parents.Count == 0)
         {
             node.distributions = new NoParentNodeNumericalNonShared(node);
         }
         else
         {
             int numCategorical = 0;
             foreach (var parent in node.parents)
             {
                 numCategorical += parent.distributionType == DistributionType.Categorical ? 1 : 0;
             }
             if (numCategorical == node.parents.Count)
             {
                 if (node.parents.Count == 1)
                 {
                     node.distributions = new OneCategoricalParentNodeNumericalNonShared(node);
                 }
                 else if (node.parents.Count == 2)
                 {
                     throw new ArgumentException("Only up to 2 Categorical Parents Allowed");
                 }
                 else if (node.parents.Count == 3)
                 {
                     throw new ArgumentException("Only up to 2 Categorical Parents Allowed");
                 }
             }
             else if (numCategorical == 0)
             {
                 node.distributions = new LinearRegressionNonShared(node);
             }
             else if (numCategorical == 1)
             {
                 node.distributions = new LinearRegressionOneParentNonShared(node);
             }
             else
             {
                 throw new ArgumentException("Mixed Categorical and Numerical Parents not allowed");
             }
         }
     }
     node.distributions.N = N;
 }
예제 #2
0
 public void AddNode(ModelNodeNonShared node)
 {
     nodes[node.name]            = node;
     independentNodes[node.name] = node;
 }
예제 #3
0
 public void AddChild(ModelNodeNonShared child)
 {
     children.Add(child);
 }
예제 #4
0
 public static void AddLink(ModelNodeNonShared parent, ModelNodeNonShared child)
 {
     parent.AddChild(child);
     child.AddParent(parent);
 }
예제 #5
0
 public void AddParent(ModelNodeNonShared parent)
 {
     parents.Add(parent);
 }