Package weka.core

Examples of weka.core.Instances.numAttributes()


    //filter string attributes
    dataset.nominalFilter();
    Instances data = dataset.getDataset();
   
    //set class attribute
    data.setClassIndex(data.numAttributes()-1);
   
    //set dataset
    setDataset(data);
   
    //build classifier
View Full Code Here


    attributes.addElement(strategy);
   
    //instances
    Instances data = new Instances("mydataset", attributes, 0);
   
    double[] values = new double[data.numAttributes()];
    values[0] = 0;
    values[1] = 0;
    Instances strategyData = new Instances(data.attribute(2).relation(), 0);
    double[] values4Strategy = new double[3];
    values4Strategy[0] = 0.8;
View Full Code Here

   
    Instances data = new Instances("mydataset", attributes, 0);
    for(Feedback f : feedbacks)
    {
      //instances
      double[] values = new double[data.numAttributes()];
      values[0] = f.getAssesor().id;
      values[1] = f.getAssesee().id;
      values[2] = f.value;
      data.add(new Instance(1.0, values));
    }
View Full Code Here

      String arffRelation = this.exportProperties.getProperty(
          "arffRelation", "org.apache.ctakes.ytex");
      String relation = arffRelation + "_"
          + FileUtil.getDataFilePrefix(null, label, run, fold, train);
      Instances instances = new Instances(relation, wekaAttributes, 0);
      instances.setClassIndex(instances.numAttributes() - 1);
      // add instances
      addWordsToInstances(instances, sparseData, instanceClasses);
      return instances;
    }
View Full Code Here

    for (String classLabel : bagOfWordsData.getClasses()) {
      wekaClassLabels.addElement(classLabel);
    }
    wekaAttributes.addElement(new Attribute(CLASS, wekaClassLabels));
    Instances instances = new Instances(arffRelation, wekaAttributes, 0);
    instances.setClassIndex(instances.numAttributes() - 1);
    return instances;
  }

  protected void getInstances(final String sql,
      final BagOfWordsData bagOfWordsData) {
View Full Code Here

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

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

    // traverse all instances
    for (i = 0; i < instances.numInstances(); i++) {
      oldInstance = instances.instance(i);
      oldValues   = oldInstance.toDoubleArray();
      newValues   = new double[result.numAttributes()];

      start = oldValues.length;
      if (getRemoveOldClass())
  start--;
View Full Code Here

      Instances structure = e.getStructure();
      m_legendText = new Vector();
      m_max = 1.0;
      m_min = 0;
      int i = 0;
      for (i =0; i < structure.numAttributes(); i++) {
  if (i > 10) {
    i--;
    break;
  }
  m_legendText.addElement(structure.attribute(i).name());
View Full Code Here

  //  Instances dataset = e.getInstance().dataset();
  Instances dataset = e.getStructure();
  if (m_Filter instanceof SupervisedFilter) {
    // defualt to last column if no class is set
    if (dataset.classIndex() < 0) {
      dataset.setClassIndex(dataset.numAttributes()-1);
    }
  }
  // initialize filter
  m_Filter.setInputFormat(dataset);
  // attempt to determine post-filtering
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.