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

📄 fouriergga.java

📁 一个很好的LIBSVM的JAVA源码。对于要研究和改进SVM算法的学者。可以参考。来自数据挖掘工具YALE工具包。
💻 JAVA
字号:
/*
 *  YALE - Yet Another Learning Environment
 *  Copyright (C) 2001-2004
 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, 
 *          Katharina Morik, Oliver Ritthoff
 *      Artificial Intelligence Unit
 *      Computer Science Department
 *      University of Dortmund
 *      44221 Dortmund,  Germany
 *  email: yale-team@lists.sourceforge.net
 *  web:   http://yale.cs.uni-dortmund.de/
 *
 *  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA.
 */
package edu.udo.cs.yale.operator.features.ga;

import edu.udo.cs.yale.operator.OperatorException;
import edu.udo.cs.yale.operator.parameter.*;
import edu.udo.cs.yale.operator.features.*;
import edu.udo.cs.yale.generator.*;
import edu.udo.cs.yale.tools.LogService;
import edu.udo.cs.yale.example.ExampleSet;

import java.util.List;
import java.util.LinkedList;

/** FourierGGA has all functions of YAGGA2. Additionally for each added attribute a fourier
 *  transformation is performed and the sinus function corresponding to the highest peaks
 *  are additionally added. 
 * 
 *  YAGGA is an acronym for Yet Another Generating Genetic Algorithm. 
 *  Its approach to generating new attributes differs from the original one. 
 *  The (generating) mutation can do one of the following things with 
 *  different probabilities:
 *  <ul>
 *    <li>Probability {@yale.math p/4}: Add a newly generated attribute to the feature vector</li>
 *    <li>Probability {@yale.math p/4}: Add a randomly chosen original attribute to the feature vector</li>
 *    <li>Probability {@yale.math p/2}: Remove a randomly chosen attribute from the feature vector</li>
 *  </ul>
 *  Thus it is guaranteed that the length of the feature vector can both
 *  grow and shrink. On average it will keep its original length, unless
 *  longer or shorter individuals prove to have a better fitness.
 *
 *  Since this operator does not contain algorithms to extract features from value series, it is restricted
 *  to example sets with only single attributes. For (automatic) feature extraction from values series the 
 *  value series plugin for Yale written by Ingo Mierswa should be used. It is available at 
 *  <a href="http://yale.cs.uni-dortmund.de">http://yale.cs.uni-dortmund.de</a>.
 *
 *  @version $Id: FourierGGA.java,v 2.4 2004/08/27 11:57:36 ingomierswa Exp $
 */
public class FourierGGA extends YAGGA2 {

    /** Returns the generating mutation <code>PopulationOperator</code>. */
    protected PopulationOperator getMutationPopulationOperator() throws OperatorException {	
	List generators = getGenerators();
	if (generators.size()==0) {
	    LogService.logMessage("No FeatureGenerators specified for " + getName() + ".", LogService.WARNING);
	}
	ExampleSet eSet = (ExampleSet)getInput(ExampleSet.class, false);
	List attributes = new LinkedList();
	for (int i = 0; i < eSet.getNumberOfAttributes(); i++) {
	    attributes.add(eSet.getAttribute(i));
	}
	double pMutation = getParameterAsDouble("p_mutation");
	return new FourierGeneratingMutation(attributes, pMutation, generators, 
					     getParameterAsInt("number_constructed"),
					     getParameterAsInt("number_original"),
					     getParameterAsInt("search_fourier_peaks"), 
					     getParameterAsInt("adaption_type"), 
					     getParameterAsInt("attributes_per_peak"), 
					     getParameterAsDouble("epsilon"),
					     getParameterAsInt("max_construction_depth"),
					     getParameterAsString("unused_functions").split(" "));
    }
    
    protected List getPreProcessingPopulationOperators() {
	List popOps = super.getPreProcessingPopulationOperators();
	int startSinus = getParameterAsInt("start_sinus_boost");
	if (startSinus > 0) {
	    FourierGenerator fourierGen = new FourierGenerator(getParameterAsInt("search_fourier_peaks"),
							       getParameterAsInt("adaption_type"), 
							       getParameterAsInt("attributes_per_peak"), 
							       getParameterAsDouble("epsilon"));
	    fourierGen.setStartGenerations(startSinus);
	    fourierGen.setApplyInGeneration(0);
	    popOps.add(fourierGen);
	}
	return popOps;
    }
    
    public List getParameterTypes() {
	List types = super.getParameterTypes();
	types.add(new ParameterTypeInt("number_original", 
				       "The maximum of original attributes added in each generation.", 
				       0, Integer.MAX_VALUE, 2));
	types.add(new ParameterTypeInt("number_constructed", 
				       "The maximum number of attributes constructed in each generation.", 
				       0, Integer.MAX_VALUE, 2));
	types.add(new ParameterTypeInt("max_construction_depth", 
				       "The maximum depth for the argument attributes used for attribute construction (-a: allow all depths).", 
				       -1, Integer.MAX_VALUE, -1));
	types.add(new ParameterTypeString("unused_functions", 
					  "Space separated list of functions which are not allowed in arguments for attribute construction."));
	types.add(new ParameterTypeInt("start_sinus_boost", 
				       "Uses a fourier generation in this first generations", 
				       0, Integer.MAX_VALUE, 0));
	types.add(new ParameterTypeInt("search_fourier_peaks", 
				       "Use this number of highest frequency peaks for sinus generation.", 
				       0, Integer.MAX_VALUE, 0));
	types.add(new ParameterTypeInt("attributes_per_peak", "Use this number of additional peaks for each found peak.", 
				       1, Integer.MAX_VALUE, 1));
	types.add(new ParameterTypeDouble("epsilon", "Use this range for additional peaks for each found peak.", 
					  0, Double.POSITIVE_INFINITY, 0.1));
	types.add(new ParameterTypeCategory("adaption_type", "Use this adaption type for additional peaks.",
					    SinusFactory.ADAPTION_TYPES, SinusFactory.GAUSSIAN));
	return types;
}
}

⌨️ 快捷键说明

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