Package weka.core

Examples of weka.core.FastVector$FastVectorEnumeration


    if (m_bNeedsUndoAction) {
      addUndoAction(new RenameValueAction(nTargetNode, sValue, sNewValue));
    }
    Attribute att = m_Instances.attribute(nTargetNode);
    int nCardinality = att.numValues();
    FastVector values = new FastVector(nCardinality);
    for (int iValue = 0; iValue < nCardinality; iValue++) {
      if (att.value(iValue).equals(sValue)) {
        values.addElement(sNewValue);
      } else {
        values.addElement(att.value(iValue));
      }
    }
    replaceAtt(nTargetNode, att.name(), values);
  } // renameNodeValue
View Full Code Here


    if (m_bNeedsUndoAction) {
      addUndoAction(new AddValueAction(nTargetNode, sNewValue));
    }
    Attribute att = m_Instances.attribute(nTargetNode);
    int nCardinality = att.numValues();
    FastVector values = new FastVector(nCardinality);
    for (int iValue = 0; iValue < nCardinality; iValue++) {
      values.addElement(att.value(iValue));
    }
    values.addElement(sNewValue);
    replaceAtt(nTargetNode, att.name(), values);

    // 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));
      }
View Full Code Here

    if (m_bNeedsUndoAction) {
      addUndoAction(new DelValueAction(nTargetNode, sValue));
    }
    Attribute att = m_Instances.attribute(nTargetNode);
    int nCardinality = att.numValues();
    FastVector values = new FastVector(nCardinality);
    int nValue = -1;
    for (int iValue = 0; iValue < nCardinality; iValue++) {
      if (att.value(iValue).equals(sValue)) {
        nValue = iValue;
      } else {
        values.addElement(att.value(iValue));
      }
    }
    if (nValue < 0) {
      // could not find value
      throw new Exception("Node " + nTargetNode + " does not have value (" + sValue + ")");
    }
    replaceAtt(nTargetNode, att.name(), values);

    // 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);
View Full Code Here

  /** return list of children of a node
   * @param nTargetNode index of node of interest
   */
  public FastVector getChildren(int nTargetNode) {
    FastVector children = new FastVector();
    for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
      if (m_ParentSets[iNode].contains(nTargetNode)) {
        children.addElement(iNode);
      }
    }
    return children;
  } // getChildren
View Full Code Here

    m_nCurrentEditAction++;
  } // addUndoAction

  /** remove all actions from the undo stack */
  public void clearUndoStack() {
    m_undoStack = new FastVector();
    //m_sXMLStack = new FastVector();
    m_nCurrentEditAction = -1;
    m_nSavedPointer = -1;
  } // clearUndoStack
View Full Code Here

        so = new SerializedObject(m_ParentSets[nTargetNode]);
        m_ParentSet = (ParentSet) so.getObject();
      } catch (Exception e) {
        e.printStackTrace();
      }
      m_deleteArcActions = new FastVector();
      for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
        if (m_ParentSets[iNode].contains(nTargetNode)) {
          m_deleteArcActions.addElement(new DeleteArcAction(nTargetNode, iNode));
        }
      }
View Full Code Here

    int[] m_nPosX;

    int[] m_nPosY;

    public DeleteSelectionAction(FastVector nodes) {
      m_nodes = new FastVector();
      int nNodes = nodes.size();
      m_att = new Attribute[nNodes];
      m_CPT = new Estimator[nNodes][];
      m_ParentSet = new ParentSet[nNodes];
      m_nPosX = new int[nNodes];
      m_nPosY = new int[nNodes];
      m_deleteArcActions = new FastVector();
      for (int iNode = 0; iNode < nodes.size(); iNode++) {
        int nTargetNode = (Integer) nodes.elementAt(iNode);
        m_nodes.addElement(nTargetNode);
        m_att[iNode] = m_Instances.attribute(nTargetNode);
        try {
View Full Code Here

    Estimator[][] m_CPT;

    AddArcAction(int nParent, int nChild) {
      try {
        m_nParent = nParent;
        m_children = new FastVector();
        m_children.addElement(nChild);
        //m_nChild = nChild;
        SerializedObject so = new SerializedObject(m_Distributions[nChild]);
        m_CPT = new Estimator[1][];
        m_CPT[0] = (Estimator[]) so.getObject();
View Full Code Here

    } // c'tor

    AddArcAction(int nParent, FastVector children) {
      try {
        m_nParent = nParent;
        m_children = new FastVector();
        m_CPT = new Estimator[children.size()][];
        for (int iChild = 0; iChild < children.size(); iChild++) {
          int nChild = (Integer) children.elementAt(iChild);
          m_children.addElement(nChild);
          SerializedObject so = new SerializedObject(m_Distributions[nChild]);
View Full Code Here

            return -2;
        }
    }

    private Instances initializeDataSet(int numFeatures, int neededCapacity) {
        FastVector fvAllAttributes = new FastVector(numFeatures + 1);
        Attribute tempAtt;
        for (int i = 0; i < numFeatures; i++) {
            tempAtt = new Attribute("att" + i);
            fvAllAttributes.addElement(tempAtt);
        }
        FastVector fvClassVal = new FastVector(2);
        fvClassVal.addElement("positive");
        fvClassVal.addElement("negative");
        Attribute ClassAttribute = new Attribute("theClass", fvClassVal);
        fvAllAttributes.addElement(ClassAttribute);
        // Create an empty training set
        Instances emptySet = new Instances("dataSet", fvAllAttributes, neededCapacity);
        emptySet.setClassIndex(numFeatures);
View Full Code Here

TOP

Related Classes of weka.core.FastVector$FastVectorEnumeration

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.