Package weka.core

Examples of weka.core.FastVector$FastVectorEnumeration


    if (m_CutPoints == null) {
      setOutputFormat(null);
      return;
    }
    FastVector attributes = new FastVector(getInputFormat().numAttributes());
    int classIndex = getInputFormat().classIndex();
    for(int i = 0; i < getInputFormat().numAttributes(); i++) {
      if ((m_DiscretizeCols.isInRange(i))
    && (getInputFormat().attribute(i).isNumeric())) {
  if (!m_MakeBinary) {
    FastVector attribValues = new FastVector(1);
    if (m_CutPoints[i] == null) {
      attribValues.addElement("'All'");
    } else {
      for(int j = 0; j <= m_CutPoints[i].length; j++) {
        if (j == 0) {
    attribValues.addElement("'(-inf-"
      + Utils.doubleToString(m_CutPoints[i][j], 6) + "]'");
        } else if (j == m_CutPoints[i].length) {
    attribValues.addElement("'("
      + Utils.doubleToString(m_CutPoints[i][j - 1], 6)
          + "-inf)'");
        } else {
    attribValues.addElement("'("
      + Utils.doubleToString(m_CutPoints[i][j - 1], 6) + "-"
      + Utils.doubleToString(m_CutPoints[i][j], 6) + "]'");
        }
      }
    }
    attributes.addElement(new Attribute(getInputFormat().
                attribute(i).name(),
                attribValues));
  } else {
    if (m_CutPoints[i] == null) {
      FastVector attribValues = new FastVector(1);
      attribValues.addElement("'All'");
      attributes.addElement(new Attribute(getInputFormat().
            attribute(i).name(),
            attribValues));
    } else {
      if (i < getInputFormat().classIndex()) {
        classIndex += m_CutPoints[i].length - 1;
      }
      for(int j = 0; j < m_CutPoints[i].length; j++) {
        FastVector attribValues = new FastVector(2);
        attribValues.addElement("'(-inf-"
          + Utils.doubleToString(m_CutPoints[i][j], 6) + "]'");
        attribValues.addElement("'("
          + Utils.doubleToString(m_CutPoints[i][j], 6) + "-inf)'");
        attributes.addElement(new Attribute(getInputFormat().
              attribute(i).name() + "_" + (j+1),
              attribValues));
      }
View Full Code Here


  /**
   * Set the output format if the class is nominal.
   */
  private void setOutputFormatNominal() {

    FastVector newAtts;
    int newClassIndex;
    StringBuffer attributeName;
    Instances outputFormat;
    FastVector vals;

    // Compute new attributes

    newClassIndex = getInputFormat().classIndex();
    newAtts = new FastVector();
    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if ((!att.isNominal()) ||
    (j == getInputFormat().classIndex())) {
  newAtts.addElement(att.copy());
      } else {
  if ( (att.numValues() <= 2) && (!m_TransformAll) ) {
    if (m_Numeric) {
      newAtts.addElement(new Attribute(att.name()));
    } else {
      newAtts.addElement(att.copy());
    }
  } else {

    if (j < getInputFormat().classIndex()) {
      newClassIndex += att.numValues() - 1;
    }

    // Compute values for new attributes
    for (int k = 0; k < att.numValues(); k++) {
      attributeName =
        new StringBuffer(att.name() + "=");
      attributeName.append(att.value(k));
      if (m_Numeric) {
        newAtts.
    addElement(new Attribute(attributeName.toString()));
      } else {
        vals = new FastVector(2);
        vals.addElement("f"); vals.addElement("t");
        newAtts.
    addElement(new Attribute(attributeName.toString(), vals));
      }
    }
  }
View Full Code Here

    if (m_Indices == null) {
      setOutputFormat(null);
      return;
    }
    FastVector newAtts;
    int newClassIndex;
    StringBuffer attributeName;
    Instances outputFormat;
    FastVector vals;

    // Compute new attributes

    newClassIndex = getInputFormat().classIndex();
    newAtts = new FastVector();
    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if ((!att.isNominal()) ||
    (j == getInputFormat().classIndex())) {
  newAtts.addElement(att.copy());
      } else {
  if (j < getInputFormat().classIndex())
    newClassIndex += att.numValues() - 2;
   
  // Compute values for new attributes
   
  for (int k = 1; k < att.numValues(); k++) {
    attributeName =
      new StringBuffer(att.name() + "=");
    for (int l = k; l < att.numValues(); l++) {
      if (l > k) {
        attributeName.append(',');
      }
      attributeName.append(att.value(m_Indices[j][l]));
    }
    if (m_Numeric) {
      newAtts.
        addElement(new Attribute(attributeName.toString()));
    } else {
      vals = new FastVector(2);
      vals.addElement("f"); vals.addElement("t");
      newAtts.
        addElement(new Attribute(attributeName.toString(), vals));
    }
  }
      }
View Full Code Here

   */
  protected Instances determineOutputFormat(Instances inputFormat)
    throws Exception {

    // generate header
    FastVector atts = new FastVector();
    String prefix = getAlgorithm().getSelectedTag().getReadable();
    for (int i = 0; i < getNumComponents(); i++)
      atts.addElement(new Attribute(prefix + "_" + (i+1)));
    atts.addElement(new Attribute("Class"));
    Instances result = new Instances(prefix, atts, 0);
    result.setClassIndex(result.numAttributes() - 1);
   
    return result;
  }
View Full Code Here

        new weka.classifiers.evaluation.ThresholdCurve();
      weka.classifiers.evaluation.EvaluationUtils eu =
        new weka.classifiers.evaluation.EvaluationUtils();
      //weka.classifiers.Classifier classifier = new weka.classifiers.functions.Logistic();
      weka.classifiers.Classifier classifier = new weka.classifiers.bayes.NaiveBayes();
      FastVector predictions = new FastVector();
      eu.setSeed(1);
      predictions.appendElements(eu.getCVPredictions(classifier, train, 10));
      Instances result = tc.getCurve(predictions, 0);
      PlotData2D pd = new PlotData2D(result);
      pd.m_alwaysDisplayPointsOfThisSize = 10;

      boolean[] connectPoints = new boolean[result.numInstances()];
View Full Code Here

          requestedPopSize == m_totalPopPrevious) {
        return false;
      }
     
      // First construct some Instances for the curve
      FastVector fv = new FastVector();
      fv.addElement(new Attribute("Sample Size"));
      fv.addElement(new Attribute("Cost/Benefit"));
      Instances costBenefitI = new Instances("Cost/Benefit Curve", fv, 100);
     
      // process the performance data to make this curve
      Instances performanceI = m_masterPlot.getPlotInstances();
     
View Full Code Here

  }
  m_ClassCounts = tmp2;
      }
     
      // Change the class values
      FastVector values = new FastVector(data.classAttribute().numValues());
      for (int i = 0; i < data.numClasses(); i++) {
  values.addElement(data.classAttribute().value(m_Converter[i]));
      }
      FastVector newVec = new FastVector(data.numAttributes());
      for (int i = 0; i < data.numAttributes(); i++) {
  if (i == data.classIndex()) {
    newVec.addElement(new Attribute(data.classAttribute().name(), values,
            data.classAttribute().getMetadata()));
  } else {
    newVec.addElement(data.attribute(i));
  }
      }
      Instances newInsts = new Instances(data.relationName(), newVec, 0);
      newInsts.setClassIndex(data.classIndex());
      setOutputFormat(newInsts);
View Full Code Here

  public GeneralRegressionTest(String name) {
    super(name);
  }

  protected void setUp() throws Exception {
    m_modelNames = new FastVector();
    m_dataSetNames = new FastVector();
    m_modelNames.addElement("polynomial_regression_model.xml");
    m_modelNames.addElement("HEART_NOMREG.xml");
    m_dataSetNames.addElement("Elnino_small.arff");
    m_dataSetNames.addElement("heart-c.arff");
  }
View Full Code Here

  public RegressionTest(String name) {
    super(name);
  }

  protected void setUp() throws Exception {
    m_modelNames = new FastVector();
    m_dataSetNames = new FastVector();
    m_modelNames.addElement("linear_regression_model.xml");
    m_modelNames.addElement("ELNINO_REGRESSION_SIMPLE.xml");
    m_dataSetNames.addElement("Elnino_small.arff");
    m_dataSetNames.addElement("Elnino_small.arff");
  }
View Full Code Here

    } else {
      setNumFolds(10);
    }

    String cvParam;
    m_CVParams = new FastVector();
    do {
      cvParam = Utils.getOption('P', options);
      if (cvParam.length() != 0) {
  addCVParameter(cvParam);
      }
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.