weka.core.Instances.equalHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中weka.core.Instances.equalHeaders()方法的一些代码示例,展示了Instances.equalHeaders()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instances.equalHeaders()方法的具体详情如下:
包路径:weka.core.Instances
类名称:Instances
方法名:equalHeaders

Instances.equalHeaders介绍

[英]Checks if two headers are equivalent.
[中]检查两个标头是否相等。

代码示例

代码示例来源:origin: com.googlecode.obvious/obviousx-weka

@Override
public boolean equalHeaders(Instances arg0) {
 return super.equalHeaders(arg0);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/NNge

/**
 * Updates the classifier using the given instance.
 *
 * @param instance the instance to include
 * @throws Exception if instance could not be incorporated
 * successfully
 */
public void updateClassifier(Instance instance) throws Exception {
 if (m_Train.equalHeaders(instance.dataset()) == false) {
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 }    
 update(instance);    
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Sets a value of a relation-valued attribute. Creates a fresh list of
 * attribute values before it is set.
 * 
 * @param index the value's index
 * @param data the value
 * @throws IllegalArgumentException if the attribute is not relation-valued.
 */
final void setValue(int index, Instances data) {
 if (isRelationValued()) {
  if (!data.equalHeaders(((RelationalAttributeInfo)m_AttributeInfo).m_Header)) {
   throw new IllegalArgumentException("Can't set relational value. "
    + "Headers not compatible.\n" + data.equalHeadersMsg(((RelationalAttributeInfo)m_AttributeInfo).m_Header));
  }
  ((NominalAttributeInfo)m_AttributeInfo).m_Values = 
   Utils.cast(((NominalAttributeInfo)m_AttributeInfo).m_Values.clone());
  ((NominalAttributeInfo)m_AttributeInfo).m_Values.set(index, data);
 } else {
  throw new IllegalArgumentException("Can only set value for"
   + " relation-valued attributes!");
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Sets the current instance to be the supplied instance
 * 
 * @param instance instance to be set as the current instance
 */
public void setInstance(Instance instance) {
 assert dataset.equalHeaders(instance.dataset());
 this.instance = instance;
 missingAccessed = false;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Sets a value of a relation-valued attribute. Creates a fresh list of
 * attribute values before it is set.
 * 
 * @param index the value's index
 * @param data the value
 * @throws IllegalArgumentException if the attribute is not relation-valued.
 */
final void setValue(int index, Instances data) {
 if (isRelationValued()) {
  if (!data.equalHeaders(((RelationalAttributeInfo)m_AttributeInfo).m_Header)) {
   throw new IllegalArgumentException("Can't set relational value. "
    + "Headers not compatible.\n" + data.equalHeadersMsg(((RelationalAttributeInfo)m_AttributeInfo).m_Header));
  }
  ((NominalAttributeInfo)m_AttributeInfo).m_Values = 
   Utils.cast(((NominalAttributeInfo)m_AttributeInfo).m_Values.clone());
  ((NominalAttributeInfo)m_AttributeInfo).m_Values.set(index, data);
 } else {
  throw new IllegalArgumentException("Can only set value for"
   + " relation-valued attributes!");
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Sets the current instance to be the supplied instance
 * 
 * @param instance instance to be set as the current instance
 */
public void setInstance(Instance instance) {
 assert dataset.equalHeaders(instance.dataset());
 this.instance = instance;
 missingAccessed = false;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

if (!m_data.equalHeaders(toAggregate.m_data)) {
 throw new Exception("Can't aggregate - data headers dont match: "
   + m_data.equalHeadersMsg(toAggregate.m_data));

代码示例来源:origin: com.googlecode.obvious/obviousx-weka

@Override
public boolean equalHeaders(Instance inst) {
 return dataset().equalHeaders(inst.dataset());
}

代码示例来源:origin: nz.ac.waikato.cms.weka/NNge

/**
 * Classifies a given instance.
 *
 * @param instance the instance to be classified
 * @return index of the predicted class as a double
 * @throws Exception if instance could not be classified
 * successfully
 */
public double classifyInstance(Instance instance) throws Exception {
 /* check the instance */
 if (m_Train.equalHeaders(instance.dataset()) == false){
  throw new Exception("NNge.classifyInstance : Incompatible instance types !\n" + m_Train.equalHeadersMsg(instance.dataset()));
 }
 
 Exemplar matched = nearestExemplar(instance); 
 if(matched == null){
  throw new Exception("NNge.classifyInstance : NNge hasn't been trained !");
 }
 return matched.classValue();
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Tests if the headers of two instances are equivalent.
 * 
 * @param inst another instance
 * @return true if the header of the given instance is equivalent to this
 *         instance's header
 * @throws UnassignedDatasetException if instance doesn't have access to any
 *           dataset
 */
// @ requires m_Dataset != null;
@Override
public/* @pure@ */boolean equalHeaders(Instance inst) {
 if (m_Dataset == null) {
  throw new UnassignedDatasetException(
   "Instance doesn't have access to a dataset!");
 }
 return m_Dataset.equalHeaders(inst.dataset());
}

代码示例来源:origin: Waikato/weka-trunk

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public NaiveBayes aggregate(NaiveBayes toAggregate) throws Exception {
 // Highly unlikely that discretization intervals will match between the
 // two classifiers
 if (m_UseDiscretization || toAggregate.getUseSupervisedDiscretization()) {
  throw new Exception("Unable to aggregate when supervised discretization "
   + "has been turned on");
 }
 if (!m_Instances.equalHeaders(toAggregate.m_Instances)) {
  throw new Exception("Can't aggregate - data headers don't match: "
   + m_Instances.equalHeadersMsg(toAggregate.m_Instances));
 }
 ((Aggregateable) m_ClassDistribution)
  .aggregate(toAggregate.m_ClassDistribution);
 // aggregate all conditional estimators
 for (int i = 0; i < m_Distributions.length; i++) {
  for (int j = 0; j < m_Distributions[i].length; j++) {
   ((Aggregateable) m_Distributions[i][j])
    .aggregate(toAggregate.m_Distributions[i][j]);
  }
 }
 return this;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Tests if the headers of two instances are equivalent.
 * 
 * @param inst another instance
 * @return true if the header of the given instance is equivalent to this
 *         instance's header
 * @throws UnassignedDatasetException if instance doesn't have access to any
 *           dataset
 */
// @ requires m_Dataset != null;
@Override
public/* @pure@ */boolean equalHeaders(Instance inst) {
 if (m_Dataset == null) {
  throw new UnassignedDatasetException(
   "Instance doesn't have access to a dataset!");
 }
 return m_Dataset.equalHeaders(inst.dataset());
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public NaiveBayes aggregate(NaiveBayes toAggregate) throws Exception {
 // Highly unlikely that discretization intervals will match between the
 // two classifiers
 if (m_UseDiscretization || toAggregate.getUseSupervisedDiscretization()) {
  throw new Exception("Unable to aggregate when supervised discretization "
   + "has been turned on");
 }
 if (!m_Instances.equalHeaders(toAggregate.m_Instances)) {
  throw new Exception("Can't aggregate - data headers don't match: "
   + m_Instances.equalHeadersMsg(toAggregate.m_Instances));
 }
 ((Aggregateable) m_ClassDistribution)
  .aggregate(toAggregate.m_ClassDistribution);
 // aggregate all conditional estimators
 for (int i = 0; i < m_Distributions.length; i++) {
  for (int j = 0; j < m_Distributions[i].length; j++) {
   ((Aggregateable) m_Distributions[i][j])
    .aggregate(toAggregate.m_Distributions[i][j]);
  }
 }
 return this;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Add a plot to the list of plots to display
 * 
 * @param newPlot the new plot to add
 * @exception Exception if the plot could not be added
 */
public void addPlot(PlotData2D newPlot) throws Exception {
 if (newPlot.m_plotInstances == null) {
  throw new Exception("No instances in plot data!");
 }
 if (m_masterPlot != null) {
  if (m_masterPlot.m_plotInstances.equalHeaders(newPlot.m_plotInstances) == false) {
   throw new Exception("Plot2D :Plot data's instances are incompatable "
    + " with master plot");
  }
 } else {
  m_masterPlot = newPlot;
  m_plotInstances = m_masterPlot.m_plotInstances;
 }
 m_plots.add(newPlot);
 setXindex(m_xIndex);
 setYindex(m_yIndex);
 setCindex(m_cIndex);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Adds the supplied instance to the training set
 *
 * @param instance the instance to add
 * @throws Exception if instance could not be incorporated successfully
 */
public void updateClassifier(Instance instance) throws Exception {
 
 if (m_Train.equalHeaders(instance.dataset()) == false)
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 if ( instance.classIsMissing() )
  return;
 m_Train.add(instance);
 // update relevant attributes ...
 update_m_Attributes();
}

代码示例来源:origin: nz.ac.waikato.cms.weka/distributedWekaBase

/**
 * Aggregate the supplied reservoir into our reservoir. Does not increase the
 * size of the sample.
 * 
 * @param toAggregate the reservoir sample to aggregate
 * @throws Exception if the structure of the instances in the sample to
 *           aggregate does not match the structure of our sketch
 */
public void aggregateReservoir(WeightedReservoirSample toAggregate)
 throws Exception {
 if (toAggregate.getSample().size() > 0) {
  Instance structureCheck = toAggregate.getSample().peek().m_instance;
  if (!m_currentSketch.equalHeaders(structureCheck.dataset())) {
   throw new Exception(
    "Can't aggregate - instances structure is different: "
     + m_currentSketch.equalHeadersMsg(structureCheck.dataset()));
  }
 }
 m_weightedCenterSample.aggregate(toAggregate);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/simpleEducationalLearningSchemes

/**
 * Updates the classifier.
 *
 * @param instance the instance to be put into the classifier
 * @throws Exception if the instance could not be included successfully
 */
public void updateClassifier(Instance instance) throws Exception {

 if (m_Train.equalHeaders(instance.dataset()) == false) {
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 }
 if (instance.classIsMissing()) {
  return;
 }
 m_Train.add(instance);
 updateMinMax(instance);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Adds the supplied instance to the training set.
 *
 * @param instance the instance to add
 * @throws Exception if instance could not be incorporated
 * successfully
 */
public void updateClassifier(Instance instance) throws Exception {
 if (m_Train == null) {
  throw new Exception("No training instance structure set!");
 }
 else if (m_Train.equalHeaders(instance.dataset()) == false) {
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 }
 if (!instance.classIsMissing()) {
  m_NNSearch.update(instance);
  m_Train.add(instance);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Adds the supplied instance to the training set.
 *
 * @param instance the instance to add
 * @throws Exception if instance could not be incorporated
 * successfully
 */
public void updateClassifier(Instance instance) throws Exception {
 if (m_Train == null) {
  throw new Exception("No training instance structure set!");
 }
 else if (m_Train.equalHeaders(instance.dataset()) == false) {
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 }
 if (!instance.classIsMissing()) {
  m_NNSearch.update(instance);
  m_Train.add(instance);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Adds the supplied instance to the training set
 *
 * @param instance the instance to add
 * @throws Exception if instance could not be incorporated successfully
 */
public void updateClassifier(Instance instance) throws Exception {
 
 if (m_Train.equalHeaders(instance.dataset()) == false)
  throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset()));
 if ( instance.classIsMissing() )
  return;
 m_Train.add(instance);
 // update relevant attributes ...
 update_m_Attributes();
}

相关文章

Instances类方法