当前位置: 首页>>代码示例>>Java>>正文


Java Bagging类代码示例

本文整理汇总了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;
}
 
开发者ID:Eyasics,项目名称:recon,代码行数:49,代码来源:Util.java

示例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);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:43,代码来源:RandomForest.java

示例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;
    }
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:36,代码来源:AbstractWekaModel.java

示例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);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:33,代码来源:RandomForest.java

示例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);
}
 
开发者ID:umple,项目名称:umple,代码行数:42,代码来源:RandomForest.java

示例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;
}
 
开发者ID:feedzai,项目名称:fos-weka,代码行数:30,代码来源:RandomForestPMMLConsumer.java

示例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);
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:34,代码来源:RandomForest.java

示例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) ;
}
 
开发者ID:busk,项目名称:WikipediaMiner,代码行数:10,代码来源:LabelComparer.java

示例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) ;
}
 
开发者ID:busk,项目名称:WikipediaMiner,代码行数:8,代码来源:TopicIndexer.java

示例10: BagClassify

import weka.classifiers.meta.Bagging; //导入依赖的package包/类
public BagClassify() {
    super();
    this.classifier = new Bagging();
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:5,代码来源:BagClassify.java

示例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) ;
}
 
开发者ID:busk,项目名称:WikipediaMiner,代码行数:6,代码来源:Disambiguator.java


注:本文中的weka.classifiers.meta.Bagging类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。