📄 perturbationencapsulation.java
字号:
package fasbir.ensemblers;
import weka.core.*;
import weka.classifiers.Classifier;
/**
* <p>Description: Abstract class of perturbation methods</p>
* A perturbation method is a meta classifier. It produces some perturbation,
* say sample the training dataset, and train the base classifier. <br>
* So a perturbation method should be fed another classifier. e.g.<br>
* <code>
* PerturbationEncapsulation A = new ...(); <br>
* A.setSeed(seed); // set a randomization seed <br>
* A.setClassifier( another classifier ); // set base classifier<br>
* A.buildClassifier( dataset ); // train
* A.classifyInstance( data ); // test
* </code>
* @author Y. Yu (yuy@lamda.nju.edu.cn), LAMDA Group (http://lamda.nju.edu.cn/)
* @version 1.0
*/
public abstract class PerturbationEncapsulation extends Classifier implements Randomizable{
protected Classifier m_Classifier;
protected int m_Seed;
/**
* set randomization seed
* @param seed int
*/
public void setSeed(int seed) {
this.m_Seed = seed;
if (m_Classifier instanceof Randomizable)
( (Randomizable) m_Classifier).setSeed(seed);
}
/**
* get the randomization seed
* @return int
*/
public int getSeed() {
return m_Seed;
}
/**
* set the base classifier, since Perturbation_Bootstrap is a wrap of a classifier.
* @param c Classifier
*/
public void setClassifier(Classifier c) {
this.m_Classifier = c;
}
/**
* classify a given instance
* @param instance Instance
* @return double
* @throws Exception
*/
public double classifyInstance( Instance instance) throws Exception{
return m_Classifier.classifyInstance(instance);
}
/**
* class distribution is the same of base classifier's
* @param instance Instance
* @return double[]
* @throws Exception
*/
public double[] distributionForInstance(Instance instance) throws Exception {
return m_Classifier.distributionForInstance( instance );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -