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

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

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

Instances.numClasses介绍

[英]Returns the number of class labels.
[中]返回类标签的数目。

代码示例

代码示例来源:origin: Waikato/wekaDeeplearning4j

@Override
public int totalOutcomes() {
 return data.numClasses();
}

代码示例来源:origin: Waikato/wekaDeeplearning4j

@Override
public int totalOutcomes() {
  return data.numClasses();
}

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

@Override
public int numClasses() {
 return super.numClasses();
}

代码示例来源:origin: sc.fiji/Archipelago_Plugins

private static int countClasses(final File classifier) throws IOException,
    ClassNotFoundException
{
  final InputStream is = new FileInputStream( classifier );
  final ObjectInputStream objectInputStream = new ObjectInputStream(is);
  final AbstractClassifier abstractClassifier =
      (AbstractClassifier) objectInputStream.readObject();
  final Instances header = (Instances) objectInputStream.readObject();
  
  objectInputStream.close();
  
  return header.numClasses();
}

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

@Override
public int numClasses() {
 return dataset().numClasses();
}

代码示例来源:origin: Waikato/wekaDeeplearning4j

@Override
public List<String> getLabels() {
  return IntStream.range(0, data.numClasses())
      .boxed()
      .map(i -> data.classAttribute().value(i))
      .collect(Collectors.toList());
}

代码示例来源:origin: Waikato/wekaDeeplearning4j

@Override
public LabeledSentenceProvider getSentenceProvider(Instances data) {
 List<File> files = new ArrayList<>();
 List<String> labels = new ArrayList<>();
 final int clsIdx = data.classIndex();
 for (Instance inst : data) {
  labels.add(String.valueOf(inst.value(clsIdx)));
  final String path = inst.stringValue(1 - clsIdx);
  final File file = Paths.get(textsLocation.getAbsolutePath(), path).toFile();
  files.add(file);
 }
 return new FileLabeledSentenceProvider(files, labels, data.numClasses());
}

代码示例来源:origin: Waikato/wekaDeeplearning4j

@Override
public LabeledSentenceProvider getSentenceProvider(Instances data) {
 List<File> files = new ArrayList<>();
 List<String> labels = new ArrayList<>();
 final int clsIdx = data.classIndex();
 for (Instance inst : data) {
  labels.add(String.valueOf(inst.value(clsIdx)));
  final String path = inst.stringValue(1 - clsIdx);
  final File file = Paths.get(textsLocation.getAbsolutePath(), path).toFile();
  files.add(file);
 }
 return new FileLabeledSentenceProvider(files, labels, data.numClasses());
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init() {
 try {
  m_NumInstances = m_TrainSet.numInstances();
  m_NumClasses = m_TrainSet.numClasses();
  m_NumAttributes = m_TrainSet.numAttributes();
  m_ClassType = m_TrainSet.classAttribute().type();
 } catch (Exception e) {
  e.printStackTrace();
 }
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init() {
 try {
  m_NumInstances = m_TrainSet.numInstances();
  m_NumClasses = m_TrainSet.numClasses();
  m_NumAttributes = m_TrainSet.numAttributes();
  m_ClassType = m_TrainSet.classAttribute().type();
 } catch (Exception e) {
  e.printStackTrace();
 }
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init_m_Attributes() {
 try {
  m_NumInstances = m_Train.numInstances();
  m_NumClasses = m_Train.numClasses();
  m_NumAttributes = m_Train.numAttributes();
  m_ClassType = m_Train.classAttribute().type();
  m_InitFlag = ON;
 } catch(Exception e) {
  e.printStackTrace();
 }
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init() {
 try {
  m_NumInstances = m_TrainSet.numInstances();
  m_NumClasses = m_TrainSet.numClasses();
  m_NumAttributes = m_TrainSet.numAttributes();
  m_ClassType = m_TrainSet.classAttribute().type();
 } catch (Exception e) {
  e.printStackTrace();
 }
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init() {
 try {
  m_NumInstances = m_TrainSet.numInstances();
  m_NumClasses = m_TrainSet.numClasses();
  m_NumAttributes = m_TrainSet.numAttributes();
  m_ClassType = m_TrainSet.classAttribute().type();
 } catch (Exception e) {
  e.printStackTrace();
 }
}

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

/**
 * Initializes the m_Attributes of the class.
 */
private void init_m_Attributes() {
 try {
  m_NumInstances = m_Train.numInstances();
  m_NumClasses = m_Train.numClasses();
  m_NumAttributes = m_Train.numAttributes();
  m_ClassType = m_Train.classAttribute().type();
  m_InitFlag = ON;
 } catch(Exception e) {
  e.printStackTrace();
 }
}

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

public void testNominal() {
 m_Filter = getFilter();
 m_Instances.setClassIndex(1);
 Instances result = useFilter();
 // classes must be still the same
 assertEquals(m_Instances.numClasses(), result.numClasses());
 // at least one cluster per label besides class
 assertTrue(result.numAttributes() >= m_Instances.numClasses() + 1);
}

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

public void testNominal() {
 m_Filter = getFilter();
 m_Instances.setClassIndex(1);
 Instances result = useFilter();
 // classes must be still the same
 assertEquals(m_Instances.numClasses(), result.numClasses());
 // at least one cluster per label besides class
 assertTrue(result.numAttributes() >= m_Instances.numClasses() + 1);
}

代码示例来源:origin: sc.fiji/Trainable_Segmentation

/**
 * bag class for getting the result of the loaded classifier
 */
private static class LoadedClassifier {
  private AbstractClassifier newClassifier = null;
  private Instances newHeader = null;
}

代码示例来源:origin: fiji/Trainable_Segmentation

/**
 * bag class for getting the result of the loaded classifier
 */
private static class LoadedClassifier {
  private AbstractClassifier newClassifier = null;
  private Instances newHeader = null;
}

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

public void testNominal() {
 m_Filter = getFilter();
 m_Instances.setClassIndex(0);
 Instances result = useFilter();
 // classes must be still the same
 assertEquals(m_Instances.numClasses(), result.numClasses());
 // at least one attribute besides class
 assertTrue(result.numAttributes() >= 1 + 1);
}

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

public void testNominal() {
 m_Filter = getFilter();
 m_Instances.setClassIndex(0);
 Instances result = useFilter();
 // classes must be still the same
 assertEquals(m_Instances.numClasses(), result.numClasses());
 // at least one attribute besides class
 assertTrue(result.numAttributes() >= 1 + 1);
}

相关文章

Instances类方法