⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordinalattribute.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    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 2 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, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

 /**
  * Title: XELOPES Data Mining Library
  * Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
  * Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
  * Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
  * @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
  * @version 1.0
  */

package com.prudsys.pdm.Core;

import com.prudsys.pdm.Adapters.PmmlVersion20.DataField;

/**
  * Subclass of CategoricalAttribute that represents ordinal attributes. <p>
  *
  * From CWM Data Mining. <p>
  *
  * Superclasses:
  * <ul>
  *   <li> CategoricalAttribute
  * </ul>
  * Attributes:
  * <ul>
  *   <li> <i>isCyclic</i>: Indicates ordinal attributes with cyclic value ranges,
  *   in which case the first and last attributes in the ordered sequence
  *   of attributes define the base interval. <br>
  *     - type: Boolean <br>
  *     - multiplicity: exactly one
  *   <li> <i>orderingType</i>: Indicates if categories are ordered. If orderingType
  *   is inSequence then the aggregation of categories defines the
  *   ordering relation. <br>
  *     - type: OrderType <br>
  *     - multiplicity: exactly one
  * </ul>
  *
  * @see OrderType
  */
public class OrdinalAttribute extends CategoricalAttribute
{
    // -----------------------------------------------------------------------
    //  Variables declarations
    // -----------------------------------------------------------------------
    /** Is of cyclic ordering type? */
    private boolean cyclic;

    /** Ordering type. */
    private OrderType orderingType;

    /** The attribute's categories ordered. Not used. */
    protected Category category[];

    // -----------------------------------------------------------------------
    //  Constructors
    // -----------------------------------------------------------------------
    /**
     * Empty constructor.
     */
    public OrdinalAttribute()
    {
    }

    /**
     * Ordinal attribute with given name.
     *
     * @param name name of ordinal attribute
     */
    public OrdinalAttribute( String name )
    {
        this.setName(name);
    }

    // -----------------------------------------------------------------------
    //  Getter and setter methods
    // -----------------------------------------------------------------------
    /**
     * Is attribute cyclic?
     *
     * @return true if attribute is cyclic, otherwise false
     */
    public boolean isCyclic()
    {
        return cyclic;
    }

    /**
     * Sets attribute cyclic.
     *
     * @param cyclic set cyclic information of attribute
     */
    public void setCyclic(boolean cyclic)
    {
        this.cyclic = cyclic;
    }

    /**
     * Returns ordering type of attribute.
     *
     * @return ordering type of attribute
     */
    public OrderType getOrderingType()
    {
        return orderingType;
    }

    /**
     * Sets ordering type of attribute.
     *
     * @param orderingType new ordering type of attribute
     */
    public void setOrderingType(OrderType orderingType)
    {
        this.orderingType = orderingType;
    }

    // -----------------------------------------------------------------------
    //  Methods of PMML handling
    // -----------------------------------------------------------------------
    /**
     * Create PMML object DataField for use in PMML documents.
     *
     * @return PMMLs DataField object
     * @throws MiningException if can't create pmml representation for this attribute
     * @see com.prudsys.pdm.Adapters.PmmlVersion20.DataField
     */
    public Object createPmmlObject() throws MiningException
    {
        DataField dataField = (DataField) super.createPmmlObject();
        dataField.setOptype( "ordinal" );
        if (! cyclic)
          dataField.setIsCyclic( "0" );
        else
          dataField.setIsCyclic( "1" );

        return dataField;
    }

    /**
     * Reads from PMML object DataField.
     *
     * @param pmml PMMLs DataField object
     * @see com.prudsys.pdm.Adapters.PmmlVersion20.DataField
     * @exception MiningException cannot parse PMML object
     */
    public void parsePmmlObject( Object pmml ) throws MiningException
    {
        DataField dataField = (DataField) pmml;
        super.parsePmmlObject(dataField);
        cyclic = false;
        try
        {
            cyclic = Boolean.getBoolean( dataField.getIsCyclic() );
        }
        catch (Exception ex)
        {
        };
    }

    // -----------------------------------------------------------------------
    //  java.lang.Object methods
    // -----------------------------------------------------------------------
    /**
     * Copies ordinal attribute. Shallow copy.
     *
     * @return copy of ordinal attribute
     */
    public Object clone() {

      OrdinalAttribute ordAtt = new OrdinalAttribute();

      ordAtt.setName( this.getName() );
      ordAtt.dataType            = this.dataType;
      ordAtt.values              = this.values;
      ordAtt.values2indexes      = this.values2indexes;
      ordAtt.category            = this.category;
      ordAtt.taxonomy            = this.taxonomy;
      ordAtt.unboundedCategories = this.unboundedCategories;
      ordAtt.unstoredCategories  = this.unstoredCategories;

      ordAtt.orderingType        = this.orderingType;
      ordAtt.cyclic              = this.cyclic;

      return ordAtt;
    }

    /**
     * Returns attribute as string.
     *
     * @return attribute information as string
     */
    public String toString()
    {
        String description = super.toString();
        description = description + ", subtype: ordinal";
        if (cyclic)
          description = description + ", cyclic";

        return description;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -