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


Java UpdateableClassifier类代码示例

本文整理汇总了Java中weka.classifiers.UpdateableClassifier的典型用法代码示例。如果您正苦于以下问题:Java UpdateableClassifier类的具体用法?Java UpdateableClassifier怎么用?Java UpdateableClassifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpdateableClassifier类属于weka.classifiers包,在下文中一共展示了UpdateableClassifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
@Override
public void buildClassifier(Instances data) throws Exception {
  try 
  {
    if(isUpdateable())
    {
      UpdateableClassifier u = (UpdateableClassifier) clazzifier;
      for(@SuppressWarnings("unchecked")
      Enumeration<Instance> e = data.enumerateInstances(); e.hasMoreElements();)
      {
        u.updateClassifier(e.nextElement());
      }
    }
    else
      clazzifier.buildClassifier(data);
    
    lastBuildAt = System.currentTimeMillis();
  } finally {
    
  }
  
  
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:24,代码来源:IncrementalClassifierBean.java

示例2: processRow

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Processes a row of data
 * 
 * @param row the incoming row to process
 * @throws IOException if a problem occurs
 */
protected void processRow(String row) throws IOException {
  if (row != null) {
    String[] parsed = m_rowHelper.parseRowOnly(row);

    if (parsed.length != m_trainingHeader.numAttributes()) {
      throw new IOException(
        "Parsed a row that contains a different number of values than "
          + "there are attributes in the training ARFF header: " + row);
    }
    try {
      Instance toProcess =
        makeInstance(m_rowHelper, m_trainingHeader,
          (m_task.getClassifier() instanceof UpdateableClassifier),
          m_task.getForceBatchLearningForUpdateableClassifiers(), parsed);

      m_task.processInstance(toProcess);
    } catch (Exception ex) {
      throw new IOException(ex);
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:28,代码来源:WekaClassifierHadoopMapper.java

示例3: updateClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
@Override
public void updateClassifier(Instance instance) throws Exception {
  if (getPreConstructedFilter().numPendingOutput() > 0) {
    throw new Exception("Filter output queue not empty!");
  }

  if (!getPreConstructedFilter().input(instance)) {
    // throw new Exception(
    // "Can only use PreconstructedFilters that will produce an output "
    // + "Instance immediately when given an input Instance.");

    // only allow a filter to consume an instance and not buffer anything
    if (getPreConstructedFilter().numPendingOutput() > 0) {
      throw new Exception("Filter output queue not empty!");
    }

    // nothing to train on if filter does not make instance available
    return;
  }
  getPreConstructedFilter().batchFinished();
  Instance filtered = getPreConstructedFilter().output();

  ((UpdateableClassifier) getClassifier()).updateClassifier(filtered);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:25,代码来源:AggregateableFilteredClassifierUpdateable.java

示例4: updateClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Updates a classifier using the given instance.
 * 
 * @param instance the instance to included
 * @throws Exception if instance could not be incorporated successfully or not
 *           successfully filtered
 */
@Override
public void updateClassifier(Instance instance) throws Exception {
  if (m_Filter.numPendingOutput() > 0) {
    throw new Exception("Filter output queue not empty!");
  }
  if (!m_Filter.input(instance)) {
    if (m_Filter.numPendingOutput() > 0) {
      throw new Exception("Filter output queue not empty!");
    }

    // nothing to train on if the filter does not make an instance available
    return;
    // throw new
    // Exception("Filter didn't make the train instance immediately available!");
  }

  m_Filter.batchFinished();
  Instance newInstance = m_Filter.output();

  ((UpdateableClassifier) m_Classifier).updateClassifier(newInstance);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:29,代码来源:FilteredClassifierUpdateable.java

示例5: updateClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Updates the classifier with the given instance.
 *
 * @param instance the new training instance to include in the model 
 * @exception Exception if the instance could not be incorporated in
 * the model.
 */
public void updateClassifier(Instance instance) throws Exception {
  if (!instance.classIsMissing()) {

    if (m_Classifiers.length == 1) {
      ((UpdateableClassifier)m_Classifiers[0]).updateClassifier(instance);
      return;
    }

    for (int i = 0; i < m_Classifiers.length; i++) {
      if (m_Classifiers[i] != null) {
        m_ClassFilters[i].input(instance);
        Instance converted = m_ClassFilters[i].output();
        if (converted != null) {
          converted.dataset().setClassIndex(m_ClassAttribute.index());
          ((UpdateableClassifier)m_Classifiers[i]).
          updateClassifier(converted);
          
          if (m_Method == METHOD_1_AGAINST_1) {
            m_SumOfWeights[i] += converted.weight();
          }
        }
      }
    }
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:33,代码来源:MultiClassClassifierUpdateable.java

示例6: update

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
protected void update(Instance x) throws Exception {

			Instance x_ = (Instance)x.copy();
			x_.setDataset(null);

			// delete all except one (leaving a binary problem)
			// delete all the attributes (and track where our index ends up)
			int c_index = this.value;
			for(int i = excld.length-1; i >= 0; i--) {
				x_.deleteAttributeAt(excld[i]);
				if (excld[i] < this.index)
					c_index--; 
			}
			x_.setDataset(this._template);

			((UpdateableClassifier)this.classifier).updateClassifier(x_);

			if (next != null)
				next.update(x);
		}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:21,代码来源:CCUpdateable.java

示例7: updateClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
@Override
public void updateClassifier(Instance x) throws Exception {

	int L = x.classIndex();

	if(getDebug()) System.out.print("-: Updating "+L+" models");

	for(int j = 0; j < L; j++) {
		Instance x_j = (Instance)x.copy();
		x_j.setDataset(null);
		x_j = MLUtils.keepAttributesAt(x_j,new int[]{j},L);
		x_j.setDataset(m_InstancesTemplates[j]);
		((UpdateableClassifier)m_MultiClassifiers[j]).updateClassifier(x_j);
	}

	if(getDebug()) System.out.println(":- ");
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:18,代码来源:BRUpdateable.java

示例8: setClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
@Override
public void setClassifier(Classifier c) {

  if (!(c instanceof UpdateableClassifier)) {
    throw new IllegalArgumentException("Base classifier ("
      + c.getClass().getName() + ") must be updateable!");
  }

  super.setClassifier(c);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:11,代码来源:AggregateableFilteredClassifierUpdateable.java

示例9: globalInfo

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Returns a string describing this classifier.
 * 
 * @return a description of the classifier suitable for displaying in the
 *         explorer/experimenter gui
 */
@Override
public String globalInfo() {
  return super.globalInfo() + "\n"
    + "Incremental version: only takes incremental classifiers as base "
    + "classifiers (i.e., they have to implement the "
    + UpdateableClassifier.class.getName() + " interface).";
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:14,代码来源:FilteredClassifierUpdateable.java

示例10: setClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Set the base learner.
 * 
 * @param value the classifier to use.
 */
@Override
public void setClassifier(Classifier value) {
  if (!(value instanceof UpdateableClassifier)) {
    throw new IllegalArgumentException("Classifier must be derived from "
      + UpdateableClassifier.class.getName() + "!");
  } else {
    super.setClassifier(value);
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:15,代码来源:FilteredClassifierUpdateable.java

示例11: processInstance

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Process the supplied instance. Incremental classifiers are updated
 * immediately with the instance. In the case of batch learning, the instance
 * is cached in memory and the entire data set is processed in the
 * finalizeTask() method.
 *
 * @param inst the instance to train with
 * @throws DistributedWekaException if a problem occurs
 */
public void processInstance(Instance inst) throws DistributedWekaException {

  if (m_classifier instanceof UpdateableClassifier
    && !m_forceBatchForUpdateable) {
    boolean ok = true;
    if (m_totalFolds > 1 && m_foldNumber >= 1) {
      int fn = m_numInstances % m_totalFolds;

      // is this instance in our test fold?
      if (fn == (m_foldNumber - 1)) {
        ok = false;
      }
    }

    if (ok) {
      try {
        ((UpdateableClassifier) m_classifier).updateClassifier(inst);
      } catch (Exception e) {
        throw new DistributedWekaException(e);
      }
      m_numTrainingInstances++;
    }
  } else {
    // store the instance
    if (m_reservoir != null) {
      m_reservoir.input(inst);
    } else {
      m_trainingHeader.add(inst);
    }
  }

  m_numInstances++;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:43,代码来源:WekaClassifierMapTask.java

示例12: processInstance

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Process an instance for evaluation
 * 
 * @param inst the instance to process
 * @throws Exception if a problem occurs
 */
public void processInstance(Instance inst) throws Exception {
  if (m_classifier != null
    && (m_classifier instanceof UpdateableClassifier && !m_batchTrainedIncremental)) {

    boolean ok = true;
    if (m_totalFolds > 1 && m_foldNumber >= 1) {
      int fn = m_numInstances % m_totalFolds;

      // is this instance in our test fold
      if (fn != (m_foldNumber - 1)) {
        ok = false;
      }
    }

    if (ok) {
      if (m_predFrac > 0) {
        m_eval.evaluateModelOnceAndRecordPrediction(m_classifier, inst);
      } else {
        m_eval.evaluateModelOnce(m_classifier, inst);
      }
      m_numTestInstances++;
    }
  } else {
    // store the instance
    m_trainingHeader.add(inst);
  }

  m_numInstances++;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:36,代码来源:WekaClassifierEvaluationMapTask.java

示例13: buildClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
@Override
public void buildClassifier(Instances insts) throws Exception {
  if (m_Classifier == null) {
    throw new Exception("No base classifier has been set!");
  }

  if (!(m_Classifier instanceof UpdateableClassifier)) {
    throw new Exception("Base classifier must be updateable!");
  }

  super.buildClassifier(insts);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:13,代码来源:MultiClassClassifierUpdateable.java

示例14: updateClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
/**
 * Updates the classifier with the given instance.
 * 
 * @param instance the new training instance to include in the model
 * @exception Exception if the instance could not be incorporated in the
 *              model.
 */
@Override
public void updateClassifier(Instance instance) throws Exception {
  if (!instance.classIsMissing()) {

    if (m_Classifiers.length == 1) {
      ((UpdateableClassifier) m_Classifiers[0]).updateClassifier(instance);
      return;
    }

    for (int i = 0; i < m_Classifiers.length; i++) {
      if (m_Classifiers[i] != null) {
        m_ClassFilters[i].input(instance);
        Instance converted = m_ClassFilters[i].output();
        if (converted != null) {
          converted.dataset().setClassIndex(m_ClassAttribute.index());
          ((UpdateableClassifier) m_Classifiers[i])
              .updateClassifier(converted);

          if (m_Method == METHOD_1_AGAINST_1) {
            m_SumOfWeights[i] += converted.weight();
          }
        }
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:34,代码来源:MultiClassClassifierUpdateable.java

示例15: buildClassifier

import weka.classifiers.UpdateableClassifier; //导入依赖的package包/类
public void buildClassifier(Instances insts) throws Exception {
  if (m_Classifier == null) {
    throw new Exception("No base classifier has been set!");
  }
  
  if (!(m_Classifier instanceof UpdateableClassifier)) {
    throw new Exception("Base classifier must be updateable!");
  }
  
  super.buildClassifier(insts);                
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:12,代码来源:MultiClassClassifierUpdateable.java


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