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

📄 supportvectorcallback.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.1
  */
package com.prudsys.pdm.Models.Regression.SVM;

import com.prudsys.pdm.Automat.MiningAutomationCallback;
import com.prudsys.pdm.Automat.RetrospectiveCallback;
import com.prudsys.pdm.Core.MiningException;

/**
 * Calculates parameter settings for reaching a given assessment
 * criteria of Support Vector Machine.
 */
public class SupportVectorCallback extends RetrospectiveCallback
{
  /** Start value for changing C (via exponent). */
  private double start    = -2.5;

  /** Final value for changing C (via exponent). */
  private double stop     = 20.0;

  /** Step size for changing C (via exponent). */
  private double stepSize = 0.25;

  private double cost     = start;

  /**
   * Empty constructor.
   */
  public SupportVectorCallback()
  {
  }

  /**
   * Calculates new mining parameters to reach the prescribed
   * assessment interval for SVM changing the cost parameter.
   *
   * Based on a very simple approach: the cost variable is
   * increased linearly and the SV cost parameter is calculated
   * by SVCost = e^cost.
   *
   * @return status of calculation
   * @exception MiningException error during calculation
   */
  protected int runParameterCalculation() throws MiningException {

    // Get support parameter from current mining settings:
    double C = ((SupportVectorSettings) currentMiningSettings).getC();

    System.out.println("Assessment = " + currentAssessment + " C = " + C);


    // Get assessment value. Cuurently not further used:
    double minAss = miningAutomationAssignment.getMinAssessment();
    double maxAss = miningAutomationAssignment.getMaxAssessment();

    // Get number of current iterations:
    int nIter  = getNumberOfCallbackSteps() + 1;
    if (nIter == 1)
      cost = start;

    // Bound reached => stop:
    if (cost > stop)
      return MiningAutomationCallback.CALCULATION_STATUS_NO_IMPROVEMENT;

    // Calculate cost:
    double newC = Math.exp(cost);

    // Set support value to new mining settings:
    ((SupportVectorSettings) newMiningSettings).setC(newC);

    // Increase cost:
    cost = cost + stepSize;

    return CALCULATION_STATUS_SUCCESSFUL;
  }

  /**
   * Returns initial value used for calculating C (C = e^start).
   *
   * @return initial value used for calculating C
   */
  public double getStart()
  {
    return start;
  }

  /**
   * Sets initial value used for calculating C (C = e^start).
   *
   * @param start new initial value used for calculating C
   */
  public void setStart(double start)
  {
    this.start = start;
  }

  /**
   * Returns final value used for calculating C (C = e^stop).
   *
   * @return final value used for calculating C
   */
  public double getStop()
  {
    return stop;
  }

  /**
   * Sets final value used for calculating C (C = e^stop).
   *
   * @param stop new initial value used for calculating C
   */
  public void setStop(double stop)
  {
    this.stop = stop;
  }

  /**
   * Returns step size for changing C.
   *
   * @return step size for changing C
   */
  public double getStepSize()
  {
    return stepSize;
  }

  /**
   * Sets step size for changing C.
   *
   * @param stepSize new step size for changing C
   */
  public void setStepSize(double stepSize)
  {
    this.stepSize = stepSize;
  }
}

⌨️ 快捷键说明

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