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

weka.associations.AssociationRules 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 .
 */

/*
 *    AssociationRules.java
 *    Copyright (C) 2010-2012 University of Waikato, Hamilton, New Zealand
 *
 */
package weka.associations;

import java.io.Serializable;
import java.util.List;

import weka.core.OptionHandler;
import weka.core.Utils;

/**
 * Class encapsulating a list of association rules.
 * 
 * @author Mark Hall (mhall{[at]}pentaho{[dot]}com)
 * @version $Revision: 8034 $
 */
public class AssociationRules implements Serializable {
  
  /** For serialization */
  private static final long serialVersionUID = 8889198755948056749L;
  
  /** The scheme that produced these rules */
  protected String m_producer = "Unknown";
  
  /** The list of rules */
  protected List m_rules;
  
  /**
   * Constructs a new AssociationRules.
   * 
   * @param rules the list of rules.
   * @param producer a string describing the scheme that produced these rules.
   */
  public AssociationRules(List rules, String producer) {
    m_rules = rules;
    m_producer = producer;
  }
  
  /**
   * Constructs a new AssociationRules.
   * 
   * @param rules the list of rules.
   * @param producer the scheme that produced the rules.
   */
  public AssociationRules(List rules, Object producer) {
    String producerString = producer.getClass().getName();
    if (producerString.startsWith("weka.associations.")) {
      producerString = producerString.substring("weka.associations.".length());
    }    
    
    if (producer instanceof OptionHandler) {
      String [] o = ((OptionHandler) producer).getOptions();
      producerString += " " + Utils.joinOptions(o);
    }
    
    m_rules = rules;
    m_producer = producerString;
  }
  
  /**
   * Constructs a new AssociationRules.
   * 
   * @param rules the list of rules.
   */
  public AssociationRules(List rules) {
    this(rules, "Unknown");
  }
  
  /**
   * Set the rules to use.
   * 
   * @param rules the rules to use.
   */
  public void setRules(List rules) {
    m_rules = rules;
  }
  
  /**
   * Get the rules.
   * 
   * @return the rules.
   */
  public List getRules() {
    return m_rules;
  }
  
  /**
   * Get the number of rules.
   * 
   * @return the number of rules.
   */
  public int getNumRules() {
    return m_rules.size();
  }
  
  
  /**
   * Set a textual description of the scheme that produced
   * these rules.
   * 
   * @param producer a textual description of the scheme that produced
   * these rules.
   */
  public void setProducer(String producer) {
    m_producer = producer;
  }
  
  /**
   * Get a string describing the scheme that produced these rules.
   * 
   * @return producer
   */
  public String getProducer() {
    return m_producer;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy