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

📄 binningstream.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 Michael Thess
  * @version 1.0
  */
package com.prudsys.pdm.Transform.Special;

import com.prudsys.pdm.Core.CategoricalAttribute;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningDataSpecification;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Input.MiningInputStream;
import com.prudsys.pdm.Transform.MiningTransformationFactory;
import com.prudsys.pdm.Transform.MiningTransformationStep;
import com.prudsys.pdm.Transform.OneToMultiple.Binning;
import com.prudsys.pdm.Transform.OneToOne.Identity;

/**
 * Realization of binning for a given mining input
 * stream. Only categorical attributes are binned.
 */
public class BinningStream extends VectorTransformationStream
{
  // -----------------------------------------------------------------------
  //  Constructors
  // -----------------------------------------------------------------------
  /**
   * Empty constructor.
   */
  public BinningStream()
  {
  }

  /**
   * Constructor for given stream.
   *
   * @param inputStream mining input stream for binning
   */
  public BinningStream(MiningInputStream inputStream) {

    this.inputStream = inputStream;
  }

  // -----------------------------------------------------------------------
  //  Transformation methods
  // -----------------------------------------------------------------------
  /**
   * Creates mining transformation step for binning of categorical attributs.
   *
   * @return mining transformation step
   * @exception MiningException no input stream defined
   */
  public MiningTransformationStep createMiningTransformationStep() throws MiningException  {

      // No mining input stream defined => exception:
      if (inputStream == null)
        throw new MiningException("No mining input stream defined");

      // Mining transformation factory:
      MiningTransformationFactory mtf = new MiningTransformationFactory();

      boolean notrans = true;
      MiningDataSpecification metaData = inputStream.getMetaData();
      for (int i = 0; i < metaData.getAttributesNumber(); i++) {
        // Get attribute and name:
        MiningAttribute mAtt = metaData.getMiningAttribute(i);
        String attName = mAtt.getName();

        // Don't use excluded attributes, if defined:
        if ( excludedAttributeNames != null && excludedAttributeNames.indexOf(attName) > -1)
          continue;

        // Add binning if categorical attribute:
        if (mAtt instanceof CategoricalAttribute) {
          Binning bn = new Binning();
          bn.setFeatureName( attName );

          mtf.addOneToMultipleMapping(bn);
          notrans = false;
        };
      };

      // No transformations at all => just 1 required, use first attribute:
      if (notrans) {
        MiningAttribute mAtt = metaData.getMiningAttribute(0);
        Identity id          = new Identity();
        id.setSourceName( mAtt.getName() );
        mtf.addOneToOneMapping(id);
      };

      // Create transformation step for normalization:
      mts = mtf.createMiningTransformationStep();

      return mts;
  }

  // -----------------------------------------------------------------------
  //  Other methods
  // -----------------------------------------------------------------------
  /**
   * Returns binning description.
   *
   * @returns description of binning
   */
  public String toString() {

    String mess = "Binning stream.";

    return mess;
  }

}

⌨️ 快捷键说明

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