Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* Add.java
* Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.filters.unsupervised.attribute;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.Range;
import weka.core.RevisionUtils;
import weka.core.SelectedTag;
import weka.core.SingleIndex;
import weka.core.Tag;
import weka.core.Utils;
import weka.filters.Filter;
import weka.filters.StreamableFilter;
import weka.filters.UnsupervisedFilter;
/**
* An instance filter that adds a new attribute to the
* dataset. The new attribute will contain all missing values.
*
*
*
* Valid options are:
*
*
*
* -T <NUM|NOM|STR|DAT>
* The type of attribute to create:
* NUM = Numeric attribute
* NOM = Nominal attribute
* STR = String attribute
* DAT = Date attribute
* (default: NUM)
*
*
*
* -C <index>
* Specify where to insert the column. First and last
* are valid indexes.(default: last)
*
*
*
* -N <name>
* Name of the new attribute.
* (default: 'Unnamed')
*
*
*
* -L <label1,label2,...>
* Create nominal attribute with given labels
* (default: numeric attribute)
*
*
*
* -F <format>
* The format of the date values (see ISO-8601)
* (default: yyyy-MM-dd'T'HH:mm:ss)
*
*
*
*
* @author Len Trigg ([email protected])
* @version $Revision: 12037 $
*/
public class Add extends Filter implements UnsupervisedFilter,
StreamableFilter, OptionHandler {
/** for serialization. */
static final long serialVersionUID = 761386447332932389L;
/** the attribute type. */
public static final Tag[] TAGS_TYPE = {
new Tag(Attribute.NUMERIC, "NUM", "Numeric attribute"),
new Tag(Attribute.NOMINAL, "NOM", "Nominal attribute"),
new Tag(Attribute.STRING, "STR", "String attribute"),
new Tag(Attribute.DATE, "DAT", "Date attribute") };
/** Record the type of attribute to insert. */
protected int m_AttributeType = Attribute.NUMERIC;
/** The name for the new attribute. */
protected String m_Name = "unnamed";
/** The location to insert the new attribute. */
private final SingleIndex m_Insert = new SingleIndex("last");
/** The list of labels for nominal attribute. */
protected ArrayList m_Labels = new ArrayList();
/** The date format. */
protected String m_DateFormat = "yyyy-MM-dd'T'HH:mm:ss";
/**
* Returns a string describing this filter.
*
* @return a description of the filter suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "An instance filter that adds a new attribute to the dataset."
+ " The new attribute will contain all missing values.";
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration