Package weka.core

Examples of weka.core.Attribute.copy()


    atts.add(att.copy(att.name().replaceAll(m_Find, m_Replace)));
  else
    atts.add(att.copy(att.name().replaceFirst(m_Find, m_Replace)));
      }
      else {
  atts.add((Attribute) att.copy());
      }
    }
    result = new Instances(inputFormat.relationName(), atts, 0);
    result.setClassIndex(inputFormat.classIndex());
   
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

    // 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

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

      } 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;
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())) {
  newAtts.addElement(att.copy());
      } else {
  if (j < getInputFormat().classIndex())
    newClassIndex += att.numValues() - 2;
   
  // Compute values for new attributes
View Full Code Here

    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

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

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