All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weka.filters.unsupervised.attribute.Add Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This version represents the developer version, the "bleeding edge" of development, you could say. New functionality gets added to this version.

There is a newer version: 3.9.6
Show newest version
/*
 *   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.*;
import weka.core.Capabilities.Capability;
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)
 * 
* *
 * -W <double>
 *  The weight for the new attribute (default: 1.0)
 * 
* * * * * @author Len Trigg ([email protected]) * @version $Revision: 14511 $ */ public class Add extends Filter implements UnsupervisedFilter, StreamableFilter, OptionHandler, WeightedInstancesHandler, WeightedAttributesHandler { /** 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"; /** The weight for the new attribute. */ protected double m_Weight = 1.0; /** * 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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy