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

📄 decisiontreesettings.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)
 * @author Michael Thess
 * @version 1.1
 */
package com.prudsys.pdm.Models.Classification.DecisionTree;

import com.prudsys.pdm.Models.Classification.ClassificationSettings;

/**
  * Parameters for computing a decision tree model. <p>
  *
  * Surrogates are node predicates that best mimic the action of the
  * primary split predicate. These surrogates, if they exist, are
  * applied during scoring when data is missing that is required for evaluation
  * of the primary split predicate. The surrogates are ranked in
  * accordance with how well they mimic the action of the primary predicate.
  * In the event of multiple missing data elements in a record to be scored,
  * the highest ranked surrogate with non-missing predicate data is applied.
  *
  * The termination criteria preclude further splitting of a node, which
  * enhances build performance.
  *
  * The number of maximum splits indicates the number of child nodes of each
  * interior node. Possible values include binary (exactly 2 children per
  * interior node) or k-ary alternatives at a node (2 or more children per
  * interior node). k-ary trees can have a variable number of children per
  * interior node.
  *
  * This class is based on JDM but modified; especially all parameters of
  * pruning and statistics are removed because they are used via the
  * XELOPES assessment and callback classes.
  *
  * From PDM CWM extension; based on JSR 73. <p>
  *
  * Superclasses:
  * <ul>
  *   <li> ClassificationSettings
  * </ul>
  */
public class DecisionTreeSettings extends ClassificationSettings
{
    // -----------------------------------------------------------------------
    //  Constants of decision tree settings
    // -----------------------------------------------------------------------
    /** Use vector counts as unit of minimum node size. */
    public static final int SIZE_UNIT_COUNT = 0;

    /** Use percentage as unit of minimum node size. */
    public static final int SIZE_UNIT_PERCENTAGE = 1;

    // -----------------------------------------------------------------------
    //  Variables declarations
    // -----------------------------------------------------------------------
    /** Maximum number of surrogate splits. */
    private int maxSurrogates = 0;

    /** Maximum depth of tree model. */
    private int maxDepth = Integer.MAX_VALUE;

    /** Maximum number of children of each node. */
    private int maxSplits = Integer.MAX_VALUE;

    /** Minimum node size. */
    private double minNodeSize = 0;

    /** Measure unit of minimum node size. */
    private int minNodeSizeUnit = SIZE_UNIT_PERCENTAGE;

    /** Minimum decrease of impurity. */
    private double minDecreaseInImpurity = 0.0;

    // -----------------------------------------------------------------------
    //  Getter and setter methods
    // -----------------------------------------------------------------------
    /**
     * Returns the maximum depth of the tree model to be built.
     *
     * @return maximum depth of tree
     */
    public int getMaxDepth()
    {
      return maxDepth;
    }

    /**
     * Sets the maximum depth of the tree model to be built.
     * This is a termination criterion. The build process halts the search
     * for extensions of any node at this depth.
     *
     * @param maxDepth maximum depth of the tree
     */
    public void setMaxDepth(int maxDepth)
    {
      this.maxDepth = maxDepth;
    }

    /**
     * Returns the maximum number of surrogate splits to be computed
     * by the model at each node.
     *
     * @return maximum number of surrogate splits
     */
    public int getMaxSurrogates()
    {
      return maxSurrogates;
    }

    /**
     * Sets the maximum number of surrogate splits to be computed by the
     * model at each node.
     *
     * @param maxSurrogates maximum number of surrogate splits
     */
    public void setMaxSurrogates(int maxSurrogates)
    {
      this.maxSurrogates = maxSurrogates;
    }

    /**
     * Returns the minimum decrease in impurity required to justify
     * splitting a node.
     *
     * @return minimum decrease in impurity
     */
    public double getMinDecreaseInImpurity()
    {
      return minDecreaseInImpurity;
    }

    /**
     * Sets the minimum decrease in impurity required to justify
     * splitting a node. This is a termination criterion. If no
     * candidate split can be found with a decrease greater than
     * the minimum, then the build process halts.
     *
     * @param minDecreaseInImpurity minimum decrease in impurity
     * required to justify splitting a node
     */
    public void setMinDecreaseInImpurity(double minDecreaseInImpurity)
    {
      this.minDecreaseInImpurity = minDecreaseInImpurity;
    }

    /**
     * Returns the minimum node size. If the unit is count, returns
     * the number of cases. If the unit is percentage, returns the
     * percentage of the minimum number of cases per node.
     *
     * @return minimum node size
     */
    public double getMinNodeSize()
    {
      return minNodeSize;
    }

    /**
     * Sets the minimum node size. If unit is count, size is the number
     * of cases. If unit is percentage, size is the percentage of the
     * minimum number of cases per node.
     *
     * @param minNodeSize minimum node size
     * @param unit unit of the size
     */
    public void setMinNodeSize(double minNodeSize, int unit)
    {
      this.minNodeSize     = minNodeSize;
      this.minNodeSizeUnit = unit;
    }

    /**
     * Returns the size unit of the minimum node size.
     *
     * @return size unit
     */
    public int getMinNodeSizeUnit()
    {
      return minNodeSizeUnit;
    }

    /**
     * Sets the size unit of the minimum node size.
     *
     * @param minNodeSizeUnit new size unit
     */
    public void setMinNodeSizeUnit(int minNodeSizeUnit)
    {
      this.minNodeSizeUnit = minNodeSizeUnit;
    }

    /**
     * Returns the maximum number of children at any interior node.
     * Choices are binary or k-ary where k >= 2.
     *
     * @return maximum number of children
     */
    public int getMaxSplits()
    {
      return maxSplits;
    }

    /**
     * Sets the maximum number of children at any interior node.
     * Choices are binary ork-ary where k >= 2.
     *
     * @param maxSplits maximum number of splits
     */
    public void setMaxSplits(int maxSplits)
    {
      this.maxSplits = maxSplits;
    }

    /**
     * Returns settings as string.
     *
     * @return settings as string
     */
    public String toString()
    {
        return "Decision tree\n" +
        "Target attribute = \"" + target + "\"" + "\n" +
        "maxDept = " + maxDepth + "\n" +
        "maxSplits = " + maxSplits + "\n" +
        "minNodeSize = " + minNodeSize + "\n" +
        "minNodeSizeUnit = " + minNodeSizeUnit + "\n" +
        "maxSurrogates = " + maxSurrogates + "\n" +
        "minDecreauseInImpurity = " + minDecreaseInImpurity;
    }

    /**
     * Returns settings as HTML string.
     *
     * @return settings as HTML string
     */
    public String toHtmlString()
    {
        String description = "Model:&nbsp;Decision tree<br>" +
        "<a href=http://this?Target>Target attribute&nbsp;=&nbsp;<font color=red><b>" + target + "</b></color></a>";
        return description;
    }
}

⌨️ 快捷键说明

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