📄 directedgga.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.tools.LogService;
import edu.udo.cs.yale.example.Attribute;
import edu.udo.cs.yale.example.ExampleSet;
import edu.udo.cs.yale.example.Tools;
import java.util.List;
/** DirectedGGA is an acronym for a Generating Genetic Algorithm which uses probability directed
* search heuristics to select attributes for generation or removing.
* Its approach to generating new attributes differs from the original one and is the same as the one
* of {@link YAGGA}. <br/>
*
* 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.<br/>
*
* In addition to these mutation heuristics probablilities based on the weights of the attributes are
* calculated. It is more likely for attributes with a great weight to be selected for generating new
* attributes. On the other hand the probability for removing an attribute from the example set will
* decrease for attributes with great weights. This decreases the amount of needed generations drastically. <br/>
*
* Another enhancement in comparison to the original GGA is the addition of several generators like
* the ones for trigonometric or exponential functions. In this way a sinple linear working learning scheme which
* can deliver weights can be used as inner operator. If this learner can also estimate its performance it is not
* longer necessary to use a inner cross-validation which also decreases learning time. Such a learner is
* for example the {@link edu.udo.cs.yale.operator.learner.kernel.JMySVMLearner} which delivers the xi-alpha
* performance estimation at least for classification tasks. <br/>.
*
* Summarized the advantages of this feature construction algorithm are smaller runtimes and smaller
* attribute sets as result. These attribute sets increase performance and can be used to explain the
* models of more complex learning schemes like SVMs. The additional generators allow the construction
* of features which are not possible by the known kernel functions. <br/>
*
* 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
* <tt>http://yale.cs.uni-dortmund.de</tt>.
*
* @version $Id: DirectedGGA.java,v 2.9 2004/08/27 11:57:36 ingomierswa Exp $
*/
public class DirectedGGA extends YAGGA2 {
/** Returns the {@link DirectedGeneratingMutation}. */
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);
Attribute[] attributes = new Attribute[eSet.getNumberOfAttributes()];
for (int i = 0; i < eSet.getNumberOfAttributes(); i++) {
attributes[i] = eSet.getAttribute(i);
}
return new DirectedGeneratingMutation(attributes,
getParameterAsDouble("p_mutation"),
generators,
getParameterAsInt("max_generated"),
getParameterAsInt("max_original"),
getParameterAsInt("max_construction_depth"),
getParameterAsString("unused_functions").split(" "));
}
public List getParameterTypes() {
List types = super.getParameterTypes();
types.add(new ParameterTypeInt("max_generated",
"The maximum number of generated attributes per generation.",
1, Integer.MAX_VALUE, 2));
types.add(new ParameterTypeInt("max_original",
"The maximum number of original attributes added per generation.",
1, 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."));
return types;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -