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

📄 neuralnetworksettings.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.2
 */
package com.prudsys.pdm.Models.Regression.NeuralNetwork;

import com.prudsys.pdm.Core.MiningSettings;
import com.prudsys.pdm.Models.Regression.RegressionSettings;

/**
  * Parameters for computing neural network models. <p>
  *
  * @see MiningSettings
  * @see RegressionSettings
  */
public class NeuralNetworkSettings extends RegressionSettings
{
    // -----------------------------------------------------------------------
    //  Constants representing the learning algorithm type
    // -----------------------------------------------------------------------
    /** Backpropagation learning algorithm. */
    public static final int BACK_PROPAGATION = 0;

    /** Backpropagation with momentum learning algorithm. */
    public static final int BACK_PROPAGATION_WITH_MOMENTUM = 1;

    // -----------------------------------------------------------------------
    //  Variables declarations
    // -----------------------------------------------------------------------
    /** Type of learning algorithm. */
    private int learningType = BACK_PROPAGATION_WITH_MOMENTUM;

    /** Algorithm automatically builds the neural network. */
    private boolean autoBuildNetwork = true;

    /** Learning rate of backpropagation method. */
    private double learningRate = 0.5;

    /** Momentum of backpropagation method, if used. */
    private double momentum = 0.3;

    /** Maximum number of iterations. */
    private int maxNumberOfIterations = 400;

    /** Maximum acceptable error of training the network. */
    private double maxError = 1.0E-35;

    /** Neural network object, if algorithm doesn't build it automatically. */
    private NeuralNetwork neuralNetwork = null;

    // -----------------------------------------------------------------------
    //  Getter and setter methods
    // -----------------------------------------------------------------------
    /**
     * Returns type of learning algorithm. At present, there
     * exist backpropagation (a gradient descent method) and
     * backpropagation with momentum term (a simplified conjugate
     * gradient descent method).
     *
     * @return type of learning algorithm
     */
    public int getLearningType()
    {
      return learningType;
    }

    /**
     * Sets type of learning algorithm. At present, there
     * exist backpropagation (a gradient descent method) and
     * backpropagation with momentum term (a simplified conjugate
     * gradient descent method).
     *
     * @param learningType new type of learning algorithm
     */
    public void setLearningType(int learningType)
    {
      this.learningType = learningType;
    }

    /**
     * Does learning algorithm automatically builds network?
     *
     * @return true if automatically build network, false otherwise
     */
    public boolean isAutoBuildNetwork()
    {
      return autoBuildNetwork;
    }

    /**
     * Set learning algorithm to automatically build network.
     *
     * @param autoBuildNetwork set automatically build network
     */
    public void setAutoBuildNetwork(boolean autoBuildNetwork)
    {
      this.autoBuildNetwork = autoBuildNetwork;
    }

    /**
     * Returns learning rate of backpropagation algorithm.
     *
     * @return learning rate of algorithm
     */
    public double getLearningRate()
    {
      return learningRate;
    }

    /**
     * Sets learning rate of backpropagation algorithm.
     *
     * @param learningRate new learning rate of algorithm
     */
    public void setLearningRate(double learningRate)
    {
      this.learningRate = learningRate;
    }

    /**
     * Returns momentum term (only for backpropagation with
     * momentum algorithm).
     *
     * @return momentum term
     */
    public double getMomentum()
    {
      return momentum;
    }

    /**
     * Returns momentum term (only for backpropagation with
     * momentum algorithm).
     *
     * @param momentum new momentum term
     */
    public void setMomentum(double momentum)
    {
      this.momentum = momentum;
    }

    /**
     * Returns maximum number of iterations of training the network
     * (also refered to as epochs).
     *
     * @return maximum number of iterations
     */
    public int getMaxNumberOfIterations()
    {
      return maxNumberOfIterations;
    }

    /**
     * Sets maximum number of iterations of training the network
     * (also refered to as epochs).
     *
     * @param maxNumberOfIterations new maximum number of iterations
     */
    public void setMaxNumberOfIterations(int maxNumberOfIterations)
    {
      this.maxNumberOfIterations = maxNumberOfIterations;
    }

    /**
     * Returns maximum acceptable error of training the network.
     *
     * @return maximum acceptable training error
     */
    public double getMaxError()
    {
      return maxError;
    }

    /**
     * Sets maximum acceptable error of training the network.
     *
     * @param maxError new maximum acceptable error
     */
    public void setMaxError(double maxError)
    {
      this.maxError = maxError;
    }

    /**
     * Get neural network object. Required if algorithm does not
     * build it automatically.
     *
     * @return neural network object, null if not required
     */
    public NeuralNetwork getNeuralNetwork() {
      return neuralNetwork;
    }

    /**
     * Sets new neural network object. Required if algorithm does not
     * build it automatically.
     *
     * @param neuralNetwork new neural network object
     */
    public void setNeuralNetwork(NeuralNetwork neuralNetwork) {
      this.neuralNetwork = neuralNetwork;
    }

    // -----------------------------------------------------------------------
    //  Verify settings
    // -----------------------------------------------------------------------
    /**
     * Verify settings. Call super class method (of RegressionSettings) for
     * verifying settings and checks whether it is ensured that Neural Network
     * object will be provided to the algorithm. If settings are incomplete
     * an illegal argument exception is thrown.
     *
     * @exception IllegalArgumentException exception that is thrown for incomplete settings
     */
    public void verifySettings() throws IllegalArgumentException
    {
        super.verifySettings();
        if ( neuralNetwork == null && !autoBuildNetwork)
          throw new IllegalArgumentException("NeuralNetwork object must be provided if autoBuild is off");
        if (learningRate <= 0)
          throw new IllegalArgumentException("learning rate must be positive");
        if (momentum <= 0)
          throw new IllegalArgumentException("momentum must be positive");
        if (maxNumberOfIterations <= 0)
          throw new IllegalArgumentException("maxNumberOfIterations must be positive");
        if (maxError < 0)
          throw new IllegalArgumentException("maxError can't be negative");
    }

    /**
     * Returns settings as string.
     *
     * @return settings as string
     */
    public String toString()
    {
        return "Neural network\n" +
        "Target attribute=\"" + target + "\"";
    }

    /**
     * Returns settings as HTML string.
     *
     * @return settings as HTML string
     */
    public String toHtmlString()
    {
        String description = "Model:&nbsp;Neural Network<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 + -