Package weka.filters.unsupervised.attribute

Examples of weka.filters.unsupervised.attribute.Add


   */
  public void addInstanceNumberAttribute() {
    String originalRelationName = m_plotInstances.relationName();
    int originalClassIndex = m_plotInstances.classIndex();
    try {
      Add addF = new Add();
      addF.setAttributeName("Instance_number");
      addF.setAttributeIndex("first");
      addF.setInputFormat(m_plotInstances);
      m_plotInstances = Filter.useFilter(m_plotInstances, addF);
      m_plotInstances.setClassIndex(originalClassIndex + 1);
      for (int i = 0; i < m_plotInstances.numInstances(); i++) {
  m_plotInstances.instance(i).setValue(0,(double)i);
      }
View Full Code Here


              m_dateTimeStampBase = (long) result.instance(i).value(origIndex);
            }
            break;
          }
        }
        m_addDateMap = new Add();
        m_addDateMap.setAttributeName(m_timeStampName + "-remapped");
        m_addDateMap.setInputFormat(result);
        result = Filter.useFilter(result, m_addDateMap);

        Instance previous = result.instance(0);
View Full Code Here

      if (insts.attribute(m_timeStampName).isDate()) {
        m_derivedPeriodicMakers = new ArrayList<Filter>();
        // now add filters for each requested derived periodic value
        if (m_am) {
          // numeric binary
          Add a = new Add();
          a.setAttributeName("AM");
          a.setInputFormat(insts);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_dayOfWeek) {
          // nominal
          Add a = new Add();
          a.setAttributeName("DayOfWeek");
          a.setNominalLabels("sun,mon,tue,wed,thu,fri,sat");
          a.setInputFormat(result);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_dayOfMonth) {
          // nominal
          Add a = new Add();
          a.setAttributeName("DayOfMonth");
          a.setNominalLabels("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,"
              + "20,21,22,23,24,25,26,27,28,29,30,31");
          a.setInputFormat(result);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_numDaysInMonth) {
          Add a = new Add();
          a.setAttributeName("NumDaysInMonth");
          a.setInputFormat(insts);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_weekend) {
          // numeric binary
          Add a = new Add();
          a.setAttributeName("Weekend");
          a.setInputFormat(result);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_monthOfYear) {
          // nominal
          Add a = new Add();
          a.setAttributeName("Month");
          a.setNominalLabels("jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec");
          a.setInputFormat(result);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        if (m_quarter) {
          // nominal
          Add a = new Add();
          a.setAttributeName("Quarter");
          a.setNominalLabels("Q1,Q2,Q3,Q4");
          a.setInputFormat(result);
          result = Filter.useFilter(result, a);
          m_derivedPeriodicMakers.add(a);
        }

        // any custom date-derived periodics?
        if (m_customPeriodics != null) {
          for (String name : m_customPeriodics.keySet()) {
            List<CustomPeriodicTest> l = m_customPeriodics.get(name);
            // check to see if we should create a multi-label nominal
            // attribute instead of a numeric binary attribute. If all
            // test intervals have a non-null label then attribute will
            // be nominal
            boolean binary = false;
            String labels = "";
            Set<String> uniqueLabels = new HashSet<String>();
            for (CustomPeriodicTest t : l) {
              if (t.getLabel() == null || t.getLabel().length() == 0) {
                binary = true;
                break;
              } else {
                if (uniqueLabels.add(t.getLabel())) {
                  labels += t.getLabel() + ",";
                }
              }
            }

            Add a = new Add();
            a.setAttributeName("c_" + name);
            if (!binary) {
              labels = labels.substring(0, labels.lastIndexOf(','));
              a.setAttributeType(new SelectedTag("NOM", Add.TAGS_TYPE));
              a.setNominalLabels(labels);
            }

            a.setInputFormat(result);
            result = Filter.useFilter(result, a);
            m_derivedPeriodicMakers.add(a);
          }
        }
View Full Code Here

  tempNode.addChildNode((CNode)m_children.elementAt(i));
      }
      Instances tempInst = tempNode.m_clusterInstances;
      tempNode = null;

      Add af = new Add();
      af.setAttributeName("Cluster");
      String labels = "";
      for (int i = 0; i < m_children.size(); i++) {
  CNode temp = (CNode)m_children.elementAt(i);
  labels += ("C"+temp.m_clusterNum);
  if (i < m_children.size()-1) {
    labels+=",";
  }
      }
      af.setNominalLabels(labels);
      af.setInputFormat(tempInst);
      tempInst = Filter.useFilter(tempInst, af);
      tempInst.setRelationName("Cluster "+m_clusterNum);
     
      int z = 0;
      for (int i = 0; i < m_children.size(); i++) {
View Full Code Here

  /** Creates a configured MultiFilter */
  public Filter getConfiguredFilter() {
    MultiFilter result = new MultiFilter();
   
    Filter[] filters = new Filter[2];
    filters[0] = new Add();
    ((Add) filters[0]).setAttributeIndex("last");
    filters[1] = new AddExpression();
    ((AddExpression) filters[1]).setExpression("a3+a6");
   
    result.setFilters(filters);
View Full Code Here

   */
  public void addInstanceNumberAttribute() {
    String originalRelationName = m_plotInstances.relationName();
    int originalClassIndex = m_plotInstances.classIndex();
    try {
      Add addF = new Add();
      addF.setAttributeName(Messages.getInstance().getString("PlotData2D_AddInstanceNumberAttribute_AddF_SetAttributeName_Text"));
      addF.setAttributeIndex(Messages.getInstance().getString("PlotData2D_AddInstanceNumberAttribute_AddF_SetAttributeIndex_Text"));
      addF.setInputFormat(m_plotInstances);
      m_plotInstances = Filter.useFilter(m_plotInstances, addF);
      m_plotInstances.setClassIndex(originalClassIndex + 1);
      for (int i = 0; i < m_plotInstances.numInstances(); i++) {
  m_plotInstances.instance(i).setValue(0,(double)i);
      }
View Full Code Here

  tempNode.addChildNode((CNode)m_children.elementAt(i));
      }
      Instances tempInst = tempNode.m_clusterInstances;
      tempNode = null;

      Add af = new Add();
      af.setAttributeName("Cluster");
      String labels = "";
      for (int i = 0; i < m_children.size(); i++) {
  CNode temp = (CNode)m_children.elementAt(i);
  labels += ("C"+temp.m_clusterNum);
  if (i < m_children.size()-1) {
    labels+=",";
  }
      }
      af.setNominalLabels(labels);
      af.setInputFormat(tempInst);
      tempInst = Filter.useFilter(tempInst, af);
      tempInst.setRelationName("Cluster "+m_clusterNum);
     
      int z = 0;
      for (int i = 0; i < m_children.size(); i++) {
View Full Code Here

   * Adds an instance number attribute to the plottable instances,
   */
  public void addInstanceNumberAttribute() {
    String originalRelationName = m_plotInstances.relationName();
    try {
      Add addF = new Add();
      addF.setAttributeName("Instance_number");
      addF.setAttributeIndex("first");
      addF.setInputFormat(m_plotInstances);
      m_plotInstances = Filter.useFilter(m_plotInstances, addF);
      m_plotInstances.setClassIndex(m_plotInstances.numAttributes()-1);
      for (int i = 0; i < m_plotInstances.numInstances(); i++) {
  m_plotInstances.instance(i).setValue(0,(double)i);
      }
View Full Code Here

   */
  public void addInstanceNumberAttribute() {
    String originalRelationName = m_plotInstances.relationName();
    int originalClassIndex = m_plotInstances.classIndex();
    try {
      Add addF = new Add();
      addF.setAttributeName("Instance_number");
      addF.setAttributeIndex("first");
      addF.setInputFormat(m_plotInstances);
      m_plotInstances = Filter.useFilter(m_plotInstances, addF);
      m_plotInstances.setClassIndex(originalClassIndex + 1);
      for (int i = 0; i < m_plotInstances.numInstances(); i++) {
  m_plotInstances.instance(i).setValue(0,(double)i);
      }
View Full Code Here

  tempNode.addChildNode((CNode)m_children.elementAt(i));
      }
      Instances tempInst = tempNode.m_clusterInstances;
      tempNode = null;

      Add af = new Add();
      af.setAttributeName("Cluster");
      String labels = "";
      for (int i = 0; i < m_children.size(); i++) {
  CNode temp = (CNode)m_children.elementAt(i);
  labels += ("C"+temp.m_clusterNum);
  if (i < m_children.size()-1) {
    labels+=",";
  }
      }
      af.setNominalLabels(labels);
      af.setInputFormat(tempInst);
      tempInst = Filter.useFilter(tempInst, af);
      tempInst.setRelationName("Cluster "+m_clusterNum);
     
      int z = 0;
      for (int i = 0; i < m_children.size(); i++) {
View Full Code Here

TOP

Related Classes of weka.filters.unsupervised.attribute.Add

Copyright © 2018 www.massapicom. 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.