本文整理汇总了Java中weka.classifiers.meta.Bagging类的典型用法代码示例。如果您正苦于以下问题:Java Bagging类的具体用法?Java Bagging怎么用?Java Bagging使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bagging类属于weka.classifiers.meta包,在下文中一共展示了Bagging类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassifierClassName
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
/**
* Get classifier's class name by a short name
* */
public static String getClassifierClassName(String classifierName) {
String className = "";
switch (classifierName) {
case "SGD":
className = SGD.class.toString();
break;
case "SGDText":
className = SGDText.class.toString();
break;
case "J48":
className = J48.class.toString();
break;
case "PART":
className = PART.class.toString();
break;
case "NaiveBayes":
className = NaiveBayes.class.toString();
break;
case "NBUpdateable":
className = NaiveBayesUpdateable.class.toString();
break;
case "AdaBoostM1":
className = AdaBoostM1.class.toString();
break;
case "LogitBoost":
className = LogitBoost.class.toString();
break;
case "Bagging":
className = Bagging.class.toString();
break;
case "Stacking":
className = Stacking.class.toString();
break;
case "AdditiveRegression":
className = AdditiveRegression.class.toString();
break;
case "Apriori":
className = Apriori.class.toString();
break;
default:
className = SGD.class.toString();
}
className = className.substring(6);
return className;
}
示例2: buildClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
/**
* Builds a classifier for a set of instances.
*
* @param data the instances to train the classifier with
* @throws Exception if something goes wrong
*/
@Override
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
m_bagger = new Bagging();
// RandomTree implements WeightedInstancesHandler, so we can
// represent copies using weights to achieve speed-up.
m_bagger.setRepresentCopiesUsingWeights(true);
RandomTree rTree = new RandomTree();
// set up the random tree options
m_KValue = m_numFeatures;
if (m_KValue < 1) {
m_KValue = (int) Utils.log2(data.numAttributes() - 1) + 1;
}
rTree.setKValue(m_KValue);
rTree.setMaxDepth(getMaxDepth());
rTree.setDoNotCheckCapabilities(true);
rTree.setBreakTiesRandomly(getBreakTiesRandomly());
// set up the bagger and build the forest
m_bagger.setClassifier(rTree);
m_bagger.setSeed(m_randomSeed);
m_bagger.setNumIterations(m_numTrees);
m_bagger.setCalcOutOfBag(!getDontCalculateOutOfBagError());
m_bagger.setNumExecutionSlots(m_numExecutionSlots);
m_bagger.buildClassifier(data);
}
示例3: readFromFile
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public static Model readFromFile(String directory) throws Exception {
Classifier cls = (Classifier) weka.core.SerializationHelper.read(directory);
Class wekaClass = cls.getClass();
Model ret = null;
if(wekaClass.equals(RBFNetwork.class)){
ret = (Model) RBF.class.getConstructor().newInstance();
}
else if(wekaClass.equals(RandomSubSpace.class)){
ret = (Model) RandomSubSpaces.class.getConstructor().newInstance();
}
else if(wekaClass.equals(MultilayerPerceptron.class)){
ret = (Model) MLPerceptron.class.getConstructor().newInstance();
}
else if(wekaClass.equals(SimpleLinearRegression.class)){
ret = (Model) LinearRegression.class.getConstructor().newInstance();
}
else if(wekaClass.equals(LeastMedSq.class)){
ret = (Model) LeastSquares.class.getConstructor().newInstance();
}
else if(wekaClass.equals(IsotonicRegression.class)){
ret = (Model) IsoRegression.class.getConstructor().newInstance();
}
else if(wekaClass.equals(GaussianProcesses.class)){
ret = (Model) GaussianCurves.class.getConstructor().newInstance();
}
else if(wekaClass.equals(RegressionByDiscretization.class)){
ret = (Model) Discretization.class.getConstructor().newInstance();
}
else if(wekaClass.equals(Bagging.class)){
ret = (Model) BagClassify.class.getConstructor().newInstance();
}
ret.setClassifier(cls);
return ret;
}
示例4: buildClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
/**
* Builds a classifier for a set of instances.
*
* @param data the instances to train the classifier with
* @throws Exception if something goes wrong
*/
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
m_bagger = new Bagging();
RandomTree rTree = new RandomTree();
// set up the random tree options
m_KValue = m_numFeatures;
if (m_KValue < 1) m_KValue = (int) Utils.log2(data.numAttributes())+1;
rTree.setKValue(m_KValue);
rTree.setMaxDepth(getMaxDepth());
// set up the bagger and build the forest
m_bagger.setClassifier(rTree);
m_bagger.setSeed(m_randomSeed);
m_bagger.setNumIterations(m_numTrees);
m_bagger.setCalcOutOfBag(true);
m_bagger.setNumExecutionSlots(m_numExecutionSlots);
m_bagger.buildClassifier(data);
}
示例5: buildClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
/**
* Builds a classifier for a set of instances.
*
* @param data the instances to train the classifier with
* @throws Exception if something goes wrong
*/
@Override
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
m_bagger = new Bagging();
// RandomTree implements WeightedInstancesHandler, so we can
// represent copies using weights to achieve speed-up.
m_bagger.setRepresentCopiesUsingWeights(true);
RandomTree rTree = new RandomTree();
// set up the random tree options
m_KValue = m_numFeatures;
if (m_KValue < 1) {
m_KValue = (int) Utils.log2(data.numAttributes() - 1) + 1;
}
rTree.setKValue(m_KValue);
rTree.setMaxDepth(getMaxDepth());
rTree.setDoNotCheckCapabilities(true);
// set up the bagger and build the forest
m_bagger.setClassifier(rTree);
m_bagger.setSeed(m_randomSeed);
m_bagger.setNumIterations(m_numTrees);
m_bagger.setCalcOutOfBag(true);
m_bagger.setNumExecutionSlots(m_numExecutionSlots);
m_bagger.buildClassifier(data);
}
示例6: consume
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
@Override
public RandomForest consume(PMML pmml) throws PMMLConversionException {
MiningModel miningModel = getMiningModel(pmml);
List<Segment> segments = miningModel.getSegmentation().getSegments();
int m_numTrees = segments.size();
RandomForest randomForest = new RandomForest();
randomForest.m_bagger = new Bagging();
randomForest.m_bagger.setNumIterations(m_numTrees);
randomForest.m_bagger.setClassifier(new RandomTree());
try {
RandomForestUtils.setupBaggingClassifiers(randomForest.m_bagger);
} catch (Exception e) {
throw new PMMLConversionException("Failed to initialize bagging classifiers.", e);
}
Instances instances = buildInstances(pmml.getDataDictionary());
Classifier[] baggingClassifiers = RandomForestUtils.getBaggingClassifiers(randomForest.m_bagger);
for (int i = 0; i < baggingClassifiers.length; i++) {
RandomTree root = (RandomTree) baggingClassifiers[i];
buildRandomTree(root, instances, (TreeModel) segments.get(i).getModel());
}
return randomForest;
}
示例7: buildClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
/**
* Builds a classifier for a set of instances.
*
* @param data the instances to train the classifier with
* @throws Exception if something goes wrong
*/
@Override
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
m_bagger = new Bagging();
RandomTree rTree = new RandomTree();
// set up the random tree options
m_KValue = m_numFeatures;
if (m_KValue < 1)
m_KValue = (int) Utils.log2(data.numAttributes()) + 1;
rTree.setKValue(m_KValue);
rTree.setMaxDepth(getMaxDepth());
// set up the bagger and build the forest
m_bagger.setClassifier(rTree);
m_bagger.setSeed(m_randomSeed);
m_bagger.setNumIterations(m_numTrees);
m_bagger.setCalcOutOfBag(true);
m_bagger.buildClassifier(data);
}
示例8: buildDefaultClassifiers
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public void buildDefaultClassifiers() throws Exception {
Classifier ssClassifier = new Bagging() ;
ssClassifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ;
senseSelector.train(ssClassifier, senseDataset) ;
Classifier rmClassifier = new GaussianProcesses() ;
relatednessMeasurer.train(rmClassifier, relatednessDataset) ;
}
示例9: buildDefaultClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public void buildDefaultClassifier() throws Exception {
Logger.getLogger(TopicIndexer.class).info("building classifier") ;
Classifier classifier = new Bagging() ;
classifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ;
decider.train(classifier, dataset) ;
}
示例10: BagClassify
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public BagClassify() {
super();
this.classifier = new Bagging();
}
示例11: buildDefaultClassifier
import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public void buildDefaultClassifier() throws Exception {
Classifier classifier = new Bagging() ;
classifier.setOptions(Utils.splitOptions("-P 10 -S 1 -I 10 -W weka.classifiers.trees.J48 -- -U -M 2")) ;
decider.train(classifier, dataset) ;
}