Package weka.classifiers.bayes.net.estimate

Examples of weka.classifiers.bayes.net.estimate.DiscreteEstimatorBayes


      m_ParentSets[i] = new ParentSet();
    }
    m_Distributions = new Estimator[nNodes][];
    for (int iNode = 0; iNode < nNodes; iNode++) {
      m_Distributions[iNode] = new Estimator[1];
      m_Distributions[iNode][0] = new DiscreteEstimatorBayes(getCardinality(iNode), 0.5);
    }

    m_nEvidence = new FastVector(nNodes);
    for (int i = 0; i < nNodes; i++) {
      m_nEvidence.addElement(-1);
View Full Code Here


    Estimator[][] distributions = new Estimator[nAtts][];
    for (int iNode = 0; iNode < nAtts - 1; iNode++) {
      distributions[iNode] = m_Distributions[iNode];
    }
    distributions[nAtts - 1] = new Estimator[1];
    distributions[nAtts - 1][0] = new DiscreteEstimatorBayes(nCardinality, 0.5);
    m_Distributions = distributions;
    // update positions
    m_nPositionX.addElement(nPosX);
    m_nPositionY.addElement(nPosY);
    // update evidence & margins
View Full Code Here

      // resolve conditional probability table
      int nCardinality = parentsets[nBase + iNode].getCardinalityOfParents();
      int nValues = instances.attribute(nBase + iNode).numValues();
      distributions[nBase + iNode] = new Estimator[nCardinality];
      for (int i = 0; i < nCardinality; i++) {
        distributions[nBase + iNode][i] = new DiscreteEstimatorBayes(nValues, 0.0f);
      }

      String sTable = getContent((Element) selectElements(definition, "TABLE").elementAt(0));
      sTable = sTable.replaceAll("\\n", " ");
      StringTokenizer st = new StringTokenizer(sTable.toString());

      for (int i = 0; i < nCardinality; i++) {
        DiscreteEstimatorBayes d = (DiscreteEstimatorBayes) distributions[nBase + iNode][i];
        for (int iValue = 0; iValue < nValues; iValue++) {
          String sWeight = st.nextToken();
          d.addValue(iValue, new Double(sWeight).doubleValue());
        }
      }
      if (mode == EXECUTE) {
        m_nEvidence.insertElementAt(-1, nBase + iNode);
        m_fMarginP.insertElementAt(new double[getCardinality(nBase + iNode)], nBase + iNode);
View Full Code Here

    if (m_bNeedsUndoAction) {
      addUndoAction(new SetDistributionAction(nTargetNode, P));
    }
    Estimator[] distributions = m_Distributions[nTargetNode];
    for (int iParent = 0; iParent < distributions.length; iParent++) {
      DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(P[0].length, 0);
      for (int iValue = 0; iValue < distribution.getNumSymbols(); iValue++) {
        distribution.addValue(iValue, P[iParent][iValue]);
      }
      distributions[iParent] = distribution;
    }
    // m_Distributions[nTargetNode] = distributions;
  } // setDistribution
View Full Code Here

    // update distributions of this node
    Estimator[] distributions = m_Distributions[nTargetNode];
    int nNewCard = values.size();
    for (int iParent = 0; iParent < distributions.length; iParent++) {
      DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(nNewCard, 0);
      for (int iValue = 0; iValue < nNewCard - 1; iValue++) {
        distribution.addValue(iValue, distributions[iParent].getProbability(iValue));
      }
      distributions[iParent] = distribution;
    }

    // update distributions of all children
    for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
      if (m_ParentSets[iNode].contains(nTargetNode)) {
        distributions = m_Distributions[iNode];
        ParentSet parentSet = m_ParentSets[iNode];
        int nParentCard = parentSet.getFreshCardinalityOfParents(m_Instances);
        Estimator[] newDistributions = new Estimator[nParentCard];
        int nCard = getCardinality(iNode);
        int nParents = parentSet.getNrOfParents();
        int[] values2 = new int[nParents];
        int iOldPos = 0;
        int iTargetNode = 0;
        while (parentSet.getParent(iTargetNode) != nTargetNode) {
          iTargetNode++;
        }
        for (int iPos = 0; iPos < nParentCard; iPos++) {
          DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(nCard, 0);
          for (int iValue = 0; iValue < nCard; iValue++) {
            distribution.addValue(iValue, distributions[iOldPos].getProbability(iValue));
          }
          newDistributions[iPos] = distribution;
          // update values
          int i = 0;
          values2[i]++;
View Full Code Here

    // update distributions
    Estimator[] distributions = m_Distributions[nTargetNode];
    int nCard = values.size();
    for (int iParent = 0; iParent < distributions.length; iParent++) {
      DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(nCard, 0);
      double sum = 0;
      for (int iValue = 0; iValue < nCard; iValue++) {
        sum += distributions[iParent].getProbability(iValue);
      }
      if (sum > 0) {
        for (int iValue = 0; iValue < nCard; iValue++) {
          distribution.addValue(iValue, distributions[iParent].getProbability(iValue) / sum);
        }
      } else {
        for (int iValue = 0; iValue < nCard; iValue++) {
          distribution.addValue(iValue, 1.0 / nCard);
        }
      }
      distributions[iParent] = distribution;
    }
View Full Code Here

    Estimator[][] distributions = new Estimator[nAtts][];
    for (int iNode = 0; iNode < nAtts - 1; iNode++) {
      distributions[iNode] = m_Distributions[iNode];
    }
    distributions[nAtts - 1] = new Estimator[1];
    distributions[nAtts - 1][0] = new DiscreteEstimatorBayes(nCardinality, 0.5);
    m_Distributions = distributions;
    // update positions
    m_nPositionX.addElement(nPosX);
    m_nPositionY.addElement(nPosY);
    // update evidence & margins
View Full Code Here

      // resolve conditional probability table
      int nCardinality = parentsets[nBase + iNode].getCardinalityOfParents();
      int nValues = instances.attribute(nBase + iNode).numValues();
      distributions[nBase + iNode] = new Estimator[nCardinality];
      for (int i = 0; i < nCardinality; i++) {
        distributions[nBase + iNode][i] = new DiscreteEstimatorBayes(nValues, 0.0f);
      }

      String sTable = getContent((Element) selectElements(definition, "TABLE").elementAt(0));
      sTable = sTable.replaceAll("\\n", " ");
      StringTokenizer st = new StringTokenizer(sTable.toString());

      for (int i = 0; i < nCardinality; i++) {
        DiscreteEstimatorBayes d = (DiscreteEstimatorBayes) distributions[nBase + iNode][i];
        for (int iValue = 0; iValue < nValues; iValue++) {
          String sWeight = st.nextToken();
          d.addValue(iValue, new Double(sWeight).doubleValue());
        }
      }
      if (mode == EXECUTE) {
        m_nEvidence.insertElementAt(-1, nBase + iNode);
        m_fMarginP.insertElementAt(new double[getCardinality(nBase + iNode)], nBase + iNode);
View Full Code Here

    if (m_bNeedsUndoAction) {
      addUndoAction(new SetDistributionAction(nTargetNode, P));
    }
    Estimator[] distributions = m_Distributions[nTargetNode];
    for (int iParent = 0; iParent < distributions.length; iParent++) {
      DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(P[0].length, 0);
      for (int iValue = 0; iValue < distribution.getNumSymbols(); iValue++) {
        distribution.addValue(iValue, P[iParent][iValue]);
      }
      distributions[iParent] = distribution;
    }
    // m_Distributions[nTargetNode] = distributions;
  } // setDistribution
View Full Code Here

    // update distributions of this node
    Estimator[] distributions = m_Distributions[nTargetNode];
    int nNewCard = values.size();
    for (int iParent = 0; iParent < distributions.length; iParent++) {
      DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(nNewCard, 0);
      for (int iValue = 0; iValue < nNewCard - 1; iValue++) {
        distribution.addValue(iValue, distributions[iParent].getProbability(iValue));
      }
      distributions[iParent] = distribution;
    }

    // update distributions of all children
    for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
      if (m_ParentSets[iNode].contains(nTargetNode)) {
        distributions = m_Distributions[iNode];
        ParentSet parentSet = m_ParentSets[iNode];
        int nParentCard = parentSet.getFreshCardinalityOfParents(m_Instances);
        Estimator[] newDistributions = new Estimator[nParentCard];
        int nCard = getCardinality(iNode);
        int nParents = parentSet.getNrOfParents();
        int[] values2 = new int[nParents];
        int iOldPos = 0;
        int iTargetNode = 0;
        while (parentSet.getParent(iTargetNode) != nTargetNode) {
          iTargetNode++;
        }
        for (int iPos = 0; iPos < nParentCard; iPos++) {
          DiscreteEstimatorBayes distribution = new DiscreteEstimatorBayes(nCard, 0);
          for (int iValue = 0; iValue < nCard; iValue++) {
            distribution.addValue(iValue, distributions[iOldPos].getProbability(iValue));
          }
          newDistributions[iPos] = distribution;
          // update values
          int i = 0;
          values2[i]++;
View Full Code Here

TOP

Related Classes of weka.classifiers.bayes.net.estimate.DiscreteEstimatorBayes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.