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

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

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

Instances.variances介绍

[英]Computes the variance for all numeric attributes simultaneously. This is faster than calling variance() for each attribute. The resulting array has as many dimensions as there are attributes. Array elements corresponding to non-numeric attributes are set to 0.
[中]同时计算所有数值属性的方差。这比为每个属性调用variance()更快。结果数组的维数与属性的维数相同。与非数值属性对应的数组元素设置为0。

代码示例

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

private void checkVariance(long[] weightedValues, long var, double tol) {
 double varDouble = Double.longBitsToDouble(var);
 Instances inst = getNumericInstances();
 for (int i = 0; i < weightedValues.length; i += 2) {
  inst.add(new DenseInstance(
    Double.longBitsToDouble(weightedValues[i + 1]),
    new double[]{Double.longBitsToDouble(weightedValues[i])}
    ));
 }
 
 assertEquals("Inaccurate variance calculation!",
   varDouble, inst.variance(0), Math.abs(varDouble*tol));
 assertEquals("Inaccurate variance calculation!",
   varDouble, inst.variances()[0], Math.abs(varDouble*tol));
}

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

private void checkVariance(long[] weightedValues, long var, double tol) {
 double varDouble = Double.longBitsToDouble(var);
 Instances inst = getNumericInstances();
 for (int i = 0; i < weightedValues.length; i += 2) {
  inst.add(new DenseInstance(
    Double.longBitsToDouble(weightedValues[i + 1]),
    new double[]{Double.longBitsToDouble(weightedValues[i])}
    ));
 }
 
 assertEquals("Inaccurate variance calculation!",
   varDouble, inst.variance(0), Math.abs(varDouble*tol));
 assertEquals("Inaccurate variance calculation!",
   varDouble, inst.variances()[0], Math.abs(varDouble*tol));
}

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

/**
 * Tests the behavior of the {@link Instances.variance} and
 * {@link Instances.variances} methods.
 */
public void testVarianceBehavior() {
 Instances inst;
 
 // weight <= 1 leads to NaN variance:
 inst = getNumericInstances();
 addWeightedValues(inst, 100, 0.5);
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variance(0)));
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variances()[0]));
 // even if count > 1, weight <= 1 leads to NaN variance:
 inst = getNumericInstances();
 addWeightedValues(inst, 100, 0.5, 100, 0.3);
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variance(0)));
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variances()[0]));
 
}

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

/**
 * Tests the behavior of the {@link Instances.variance} and
 * {@link Instances.variances} methods.
 */
public void testVarianceBehavior() {
 Instances inst;
 
 // weight <= 1 leads to NaN variance:
 inst = getNumericInstances();
 addWeightedValues(inst, 100, 0.5);
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variance(0)));
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variances()[0]));
 // even if count > 1, weight <= 1 leads to NaN variance:
 inst = getNumericInstances();
 addWeightedValues(inst, 100, 0.5, 100, 0.3);
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variance(0)));
 assertTrue("Instances.variance not NaN for weight <= 1!",
   Double.isNaN(inst.variances()[0]));
 
}

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

m_ClusterMissingCounts = new double[m_NumClusters][instances.numAttributes()];
if (m_displayStdDevs) {
 m_FullStdDevs = instances.variances();
for (i = 0; i < m_NumClusters; i++) {
 if (m_displayStdDevs) {
  double[] vals2 = tempI[i].variances();
  for (int j = 0; j < instances.numAttributes(); j++) {
   if (instances.attribute(j).isNumeric()) {

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

m_ClusterMissingCounts = new double[m_NumClusters][instances.numAttributes()];
if (m_displayStdDevs) {
 m_FullStdDevs = instances.variances();
for (i = 0; i < m_NumClusters; i++) {
 if (m_displayStdDevs) {
  double[] vals2 = tempI[i].variances();
  for (int j = 0; j < instances.numAttributes(); j++) {
   if (instances.attribute(j).isNumeric()) {

相关文章

Instances类方法