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

📄 sparsegridsminingmodel.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 *    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
 * @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
 * @version 1.0
 */

package com.prudsys.pdm.Models.Regression.SparseGrids;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.Reader;
import java.io.Writer;

import com.prudsys.pdm.Adapters.PmmlVersion20.AttributeLevels;
import com.prudsys.pdm.Adapters.PmmlVersion20.DataDictionary;
import com.prudsys.pdm.Adapters.PmmlVersion20.Header;
import com.prudsys.pdm.Adapters.PmmlVersion20.MiningSchema;
import com.prudsys.pdm.Adapters.PmmlVersion20.PMML;
import com.prudsys.pdm.Adapters.PmmlVersion20.SparseGridModel;
import com.prudsys.pdm.Adapters.PmmlVersion20.TransformationDictionary;
import com.prudsys.pdm.Core.ApplicationInputSpecification;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningDataSpecification;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Core.MiningModel;
import com.prudsys.pdm.Input.MiningArrayStream;
import com.prudsys.pdm.Input.MiningInputStream;
import com.prudsys.pdm.Models.Regression.RegressionMiningModel;
import com.prudsys.pdm.Models.Supervised.SupervisedMiningModel;
import com.prudsys.pdm.Transform.MiningTransformationActivity;
import com.prudsys.pdm.Utils.PmmlUtils;

/**
  * Description of the data produced by a Sparse Grids (SG)
  * mining function. <p>
  *
  * From PDM CWM extension. <p>
  *
  * Superclasses:
  * <ul>
  *   <li> RegressionMiningModel
  * </ul>
  * Attributes:
  * <ul>
  *   <li> <i>sgType</i>: Defines the type of SG. The following types
  *   are predefined: TensorProductBasisType, SimplicialBasisType. <br>
  *     - type: Integer <br>
  *     - multiplicity: exactly one
  *   <li> <i>basisDegree</i>: Defines the polynomial degree of the
  *   sparse grid basis functions: <br>
  *     - type: Integer <br>
  *     - multiplicity: exactly one
  *   <li> <i>waveletBasis</i>: Is basis wavelet or simple
  *   hierarchical basis (non-orthogonal, e.g. Yserantant)? <br>
  *     - type: Boolean <br>
  *     - multiplicity: exactly one
  *   <li> <i>coarseGrid</i>: Go down to coarsest level 0?
  *   Otherwise the common coarse-grid level 1 is used. <br>
  *     - type: Boolean <br>
  *     - multiplicity: exactly one
  *   <li> <i>level</i>: Level for uniform mesh refinement. <br>
  *     - type: Integer <br>
  *     - multiplicity: exactly one
  *   <li> <i>attributeLevels</i>: Array of levels for all attributes
  *   if anisotropic mesh refinement is used. <br>
  *     - type: Integer[] <br>
  *     - multilplicity: exactly one
  *   <li> <i>sparseGrids</i>: Header and Coefficients of sparse grids. <br>
  *     - type: SparseGrid[] <br>
  *     - multiplicity: one or more
  * </ul>
  *
  * In addition, functionality from extended PMML was added.
  * It corresponds to the PMML element SparseGridModel.
  *
  * @see SparseGrid
  * @see MiningModel
  * @see SupervisedMiningModel
  * @see com.prudsys.pdm.Adapters.PmmlVersion20.SparseGridModel
  */
public class SparseGridsMiningModel extends RegressionMiningModel
{
  // -----------------------------------------------------------------------
  //  Variables declarations
  // -----------------------------------------------------------------------
  /** Name of Sparse Grid model. */
  private String modelName;

  /** Defines the type of SG (tensor product, simplicial). */
  private int sgType = SparseGridsSettings.SG_TENSOR_PRODUCT_BASIS_TYPE;

  /** Defines the polynomial degree of SG basis functions. */
  private int basisDegree = 1;

  /** Is wavelet basis orthogonal? Otherwise, it is just biorthogonal. */
  private boolean waveletBasis = false;

  /** Include coarse level 0 into calculations? */
  private boolean coarseGrid = false;

  /** Discretization level. */
  private int level = 1;

  /** Array of discretization levels if anisotropic grid is used. */
  private int[] attributeLevels;

  /** Array of all Sparse Grids of the model. */
  private com.prudsys.pdm.Models.Regression.SparseGrids.SparseGrid[] sparseGrids;

  // -----------------------------------------------------------------------
  //  Constructor
  // -----------------------------------------------------------------------
  /**
   * Constructor sets function and algorithm parameters.
   */
  public SparseGridsMiningModel()
  {
    function  = MiningModel.REGRESSION_FUNCTION;
    algorithm = MiningModel.SPARSE_GRIDS_ALGORITHM;
  }

  // -----------------------------------------------------------------------
  //  Getter and setter methods
  // -----------------------------------------------------------------------
  /**
   * Return number of grids.
   *
   * @return number of grids of sparse grid
   */
  public int getNumberOfGrids() {

    if (sparseGrids == null)
      return 0;

    return sparseGrids.length;
  }

  public void setModelName(String modelName)
  {
    this.modelName = modelName;
  }

  public String getModelName()
  {
    return modelName;
  }

  public void setSgType(int sgType)
  {
    this.sgType = sgType;
  }

  public int getSgType()
  {
    return sgType;
  }

  public void setBasisDegree(int basisDegree)
  {
    this.basisDegree = basisDegree;
  }

  public int getBasisDegree()
  {
    return basisDegree;
  }

  public void setWaveletBasis(boolean waveletBasis)
  {
    this.waveletBasis = waveletBasis;
  }

  public boolean isWaveletBasis()
  {
    return waveletBasis;
  }

  public void setCoarseGrid(boolean coarseGrid)
  {
    this.coarseGrid = coarseGrid;
  }
  public boolean isCoarseGrid()
  {
    return coarseGrid;
  }

  public void setLevel(int level)
  {
    this.level = level;
  }

  public int getLevel()
  {
    return level;
  }

  public void setAttributeLevels(int[] attributeLevels)
  {
    this.attributeLevels = attributeLevels;
  }

  public int[] getAttributeLevels()
  {
    return attributeLevels;
  }

  public void setSparseGrids(com.prudsys.pdm.Models.Regression.SparseGrids.SparseGrid[] sparseGrids)
  {
    this.sparseGrids = sparseGrids;
  }

  public com.prudsys.pdm.Models.Regression.SparseGrids.SparseGrid[] getSparseGrids()
  {
    return sparseGrids;
  }

  // -----------------------------------------------------------------------
  //  Methods of PMML handling
  // -----------------------------------------------------------------------
    /**
     * Write SG model to PMML document.
     *
     * @param writer writer for the PMML document
     * @exception MiningException
     */
    public void writePmml( Writer writer ) throws MiningException
    {
        PMML pmml = new PMML();
        pmml.setVersion( "2.0" );
        pmml.setHeader( (Header)PmmlUtils.getHeader() );

        // Add data and transformation dictionaries:
        MiningDataSpecification metaData = miningSettings.getDataSpecification();
        if ( metaData.isTransformed() )
        {
            pmml.setDataDictionary( (DataDictionary)metaData.getPretransformedMetaData().createPmmlObject() );
            pmml.setTransformationDictionary( (com.prudsys.pdm.Adapters.PmmlVersion20.TransformationDictionary)metaData.getMiningTransformationActivity().createPmmlObject() );
        }
        else
        {
            pmml.setDataDictionary( (DataDictionary)metaData.createPmmlObject() );
        };

        // Add SG model:
        SparseGridModel[] sgModel = new SparseGridModel[1];
        sgModel[0] = (SparseGridModel) createPmmlObject();
        pmml.setSparseGridModel( sgModel );

        // Add encoding and write to document:
        PmmlUtils.setEncoding();
        PmmlUtils.marshalPmml(writer, pmml);
    }

⌨️ 快捷键说明

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