Package weka.core

Examples of weka.core.Attribute.copy()


    newClassIndex = getInputFormat().classIndex();
    newAtts = new FastVector();
    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if ((j == newClassIndex) || (!att.isNumeric())) {
  newAtts.addElement(att.copy());
      } else {
  attributeName = new StringBuffer(att.name() + "_binarized");
  vals = new FastVector(2);
  vals.addElement("0"); vals.addElement("1");
  newAtts.addElement(new Attribute(attributeName.toString(), vals));
View Full Code Here


    m_SelectedAttributes = m_CopyCols.getSelection();
    for (int i = 0; i < m_SelectedAttributes.length; i++) {
      int current = m_SelectedAttributes[i];
      // Create a copy of the attribute with a different name
      Attribute origAttribute = instanceInfo.attribute(current);
      outputFormat.insertAttributeAt((Attribute)origAttribute.copy("Copy of " + origAttribute.name()),
             outputFormat.numAttributes());
    }

    // adapt locators
    int[] newIndices = new int[instanceInfo.numAttributes() + m_SelectedAttributes.length];
View Full Code Here

     
    newAtts = new FastVector(getInputFormat().numAttributes());
    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if (j != m_AttIndex.getIndex()) {
  newAtts.addElement(att.copy());
      } else {
   
  // Compute list of attribute values
   
  newVals = new FastVector(att.numValues());
View Full Code Here

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

    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if (j == m_AttIndex.getIndex()) {
  newAtts.addElement(new Attribute(att.name(), getDateFormat().toPattern()))
      } else {
  newAtts.addElement(att.copy());
      }
    }
     
    // Create new header
    Instances newData = new Instances(getInputFormat().relationName(), newAtts, 0);
View Full Code Here

    // now we need to rename these argument definitions to match the names of
    // the actual parameters
    ArrayList<Attribute> newParamDefs = new ArrayList<Attribute>();
    for (int i = 0; i < paramDefs.size(); i++) {
      Attribute a = paramDefs.get(i);
      newParamDefs.add(a.copy(m_parameters.get(i).getFieldName()));
    }
   
    m_parameterDefs = newParamDefs;
   
    // update the Expression
View Full Code Here

    FastVector newAtts = new FastVector(m_train.numAttributes());
    Attribute classAttribute = null;
    for (int i = 0; i < m_train.numAttributes(); i++) {
      Attribute att = m_train.attribute(i);
      if (i != m_train.classIndex()) {
  newAtts.addElement(att.copy());
      } else {
  classAttribute = new Attribute(att.name()); //numeric attribute
      }
    }
    newAtts.addElement(classAttribute);
View Full Code Here

    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if (j == m_AttIndex.getIndex()) {
  newAtts.addElement(new Attribute(att.name(), getDateFormat().toPattern()))
      } else {
  newAtts.addElement(att.copy());
      }
    }
     
    // Create new header
    Instances newData = new Instances(getInputFormat().relationName(), newAtts, 0);
View Full Code Here

     
    newAtts = new FastVector(getInputFormat().numAttributes());
    for (int j = 0; j < getInputFormat().numAttributes(); j++) {
      Attribute att = getInputFormat().attribute(j);
      if (j != m_AttIndex.getIndex()) {
  newAtts.addElement(att.copy());
      } else {
   
  // Compute list of attribute values
   
  newVals = new FastVector(att.numValues());
View Full Code Here

      // add unused attributes
      if (!getRemoveUnused()) {
  for (i = 0; i < m_IndicesUnused.length; i++) {
    att = inputFormat.attribute(m_IndicesUnused[i]);
    atts.addElement(att.copy("unfiltered-" + att.name()));
  }
      }

      // add class if present
      if (inputFormat.classIndex() > -1)
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.