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


Java Utils.eq方法代码示例

本文整理汇总了Java中weka.core.Utils.eq方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.eq方法的具体用法?Java Utils.eq怎么用?Java Utils.eq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.core.Utils的用法示例。


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

示例1: errorsForTree

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Computes error estimate for tree.
 */
private double errorsForTree() throws Exception {

  if (m_isLeaf) {
    return errorsForLeaf();
  } else {
    double error = 0;
    for (int i = 0; i < m_sons.length; i++) {
      if (Utils.eq(son(i).localModel().distribution().total(), 0)) {
        error += m_test.perBag(i)
          - m_test.perClassPerBag(i, localModel().distribution().maxClass());
      } else {
        error += ((PruneableDecList) son(i)).errorsForTree();
      }
    }

    return error;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:PruneableDecList.java

示例2: splitCritValue

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * This method computes the information gain in the same way C4.5 does.
 * 
 * @param bags the distribution
 * @param totalNoInst weight of ALL instances
 * @param oldEnt entropy with respect to "no-split"-model.
 */
public final double splitCritValue(Distribution bags, double totalNoInst,
  double oldEnt) {

  double numerator;
  double noUnknown;
  double unknownRate;
  noUnknown = totalNoInst - bags.total();
  unknownRate = noUnknown / totalNoInst;
  numerator = (oldEnt - newEnt(bags));
  numerator = (1 - unknownRate) * numerator;

  // Splits with no gain are useless.
  if (Utils.eq(numerator, 0)) {
    return 0;
  }

  return numerator / bags.total();
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:26,代码来源:InfoGainSplitCrit.java

示例3: evaluate

import weka.core.Utils; //导入方法依赖的package包/类
@Override
boolean evaluate(Instance inst, int lhsAttIndex, String rhsOperand,
  double numericOperand, Pattern regexPattern, boolean rhsIsAttribute,
  int rhsAttIndex) {

  if (rhsIsAttribute) {
    if (inst.isMissing(lhsAttIndex) && inst.isMissing(rhsAttIndex)) {
      return true;
    }
    if (inst.isMissing(lhsAttIndex) || inst.isMissing(rhsAttIndex)) {
      return false;
    }
    return Utils.eq(inst.value(lhsAttIndex), inst.value(rhsAttIndex));
  }

  if (inst.isMissing(lhsAttIndex)) {
    return false;
  }
  return (Utils.eq(inst.value(lhsAttIndex), numericOperand));
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:21,代码来源:FlowByExpression.java

示例4: addValue

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Adds a value to the density estimator.
 *
 * @param value the value to add
 * @param weight the weight of the value
 */
public void addValue(double value, double weight) {

  // Do we need to add value at all?
  if (!Utils.eq(weight, 0)) {

    // Invalidate current model
    m_MixtureModel = null;

    // Do we need to expand the arrays?
    if (m_NumValues == m_Values.length) {
      double[] newWeights = new double[2 * m_NumValues];
      double[] newValues = new double[2 * m_NumValues];
      System.arraycopy(m_Values, 0, newValues, 0, m_NumValues);
      System.arraycopy(m_Weights, 0, newWeights, 0, m_NumValues);
      m_Values = newValues;
      m_Weights = newWeights;
    }

    // Add values
    m_Values[m_NumValues] = value;
    m_Weights[m_NumValues] = weight;
    m_NumValues++;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:31,代码来源:UnivariateMixtureEstimator.java

示例5: newDistribution

import weka.core.Utils; //导入方法依赖的package包/类
/**
  * Computes new distributions of instances for nodes
  * in tree.
  *
  * @param data the data to compute the distributions for
  * @throws Exception if something goes wrong
  */
 private void newDistribution(Instances data) throws Exception {

   Instances [] localInstances;

   localModel().resetDistribution(data);
   m_train = data;
   if (!m_isLeaf){
     localInstances = 
(Instances [])localModel().split(data);
     for (int i = 0; i < m_sons.length; i++)
son(i).newDistribution(localInstances[i]);
   } else {

     // Check whether there are some instances at the leaf now!
     if (!Utils.eq(data.sumOfWeights(), 0)) {
m_isEmpty = false;
     }
   }
 }
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:27,代码来源:C45PruneableClassifierTree.java

示例6: distributionForInstance

import weka.core.Utils; //导入方法依赖的package包/类
/**
  * Calculates the class membership probabilities for the given test
  * instance.
  *
  * @param instance the instance to be classified
  * @return preedicted class probability distribution
  * @throws Exception if distribution can't be computed successfully 
  */
 @Override
 public double[] distributionForInstance(Instance instance) throws Exception {

   double [] sums = new double [instance.numClasses()], newProbs; 
   
   double numPreds = 0;
   for (int i = 0; i < m_NumIterations; i++) {
     if (instance.classAttribute().isNumeric() == true) {
       double pred = m_Classifiers[i].classifyInstance(instance);
       if (!Utils.isMissingValue(pred)) {
         sums[0] += pred;
         numPreds++;
       }
     } else {
newProbs = m_Classifiers[i].distributionForInstance(instance);
for (int j = 0; j < newProbs.length; j++)
  sums[j] += newProbs[j];
     }
   }
   if (instance.classAttribute().isNumeric() == true) {
     if (numPreds == 0) {
       sums[0] = Utils.missingValue();
     } else {
       sums[0] /= numPreds;
     }
     return sums;
   } else if (Utils.eq(Utils.sum(sums), 0)) {
     return sums;
   } else {
     Utils.normalize(sums);
     return sums;
   }
 }
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:42,代码来源:AttributeBagging.java

示例7: countsToFreqs

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Normalizes branch sizes so they contain frequencies (stored in "props")
 * instead of counts (stored in "dist"). <p>
 * 
 * Overwrites the supplied "props"! <p>
 * 
 * props.length must be == dist.length.
 */  
protected static void countsToFreqs( float[][] dist, float[] props ) {
  
  for (int k = 0; k < props.length; k++) {
    props[k] = FastRfUtils.sum(dist[k]);
  }
  if (Utils.eq(FastRfUtils.sum(props), 0)) {
    for (int k = 0; k < props.length; k++) {
      props[k] = 1.0f / (float) props.length;
    }
  } else {
    FastRfUtils.normalize(props);
  }

}
 
开发者ID:Keywords4Bytecodes,项目名称:1stclass,代码行数:23,代码来源:FastRandomTree.java

示例8: norm

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Normalizes a given value of a numeric attribute.
 * 
 * @param x the value to be normalized
 * @param i the attribute's index
 * @return the normalized value
 */
protected double norm(double x, int i) {

  if (Double.isNaN(m_Min[i]) || Utils.eq(m_Max[i], m_Min[i])) {
    return 0;
  } else {
    return (x - m_Min[i]) / (m_Max[i] - m_Min[i]);
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:16,代码来源:FarthestFirst.java

示例9: norm

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Normalizes a given value of a numeric attribute.
 * 
 * @param x the value to be normalized
 * @param i the attribute's index
 * @return the normalized value
 */
private double norm(double x, int i) {
  if (Double.isNaN(m_minArray[i]) || Utils.eq(m_maxArray[i], m_minArray[i])) {
    return 0;
  } else {
    return (x - m_minArray[i]) / (m_maxArray[i] - m_minArray[i]);
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:15,代码来源:ReliefFAttributeEval.java

示例10: distributionForInstance

import weka.core.Utils; //导入方法依赖的package包/类
/**
  * Calculates the class membership probabilities for the given test
  * instance.
  *
  * @param instance the instance to be classified
  * @return preedicted class probability distribution
  * @exception Exception if distribution can't be computed successfully 
  */
 public double[] distributionForInstance(Instance instance) throws Exception {

   double [] sums = new double [instance.numClasses()], newProbs; 
   
   double numPreds = 0;
   for (int i = 0; i < m_NumIterations; i++) {
     if (instance.classAttribute().isNumeric() == true) {
       double pred = m_Classifiers[i].classifyInstance(instance);
       if (!Utils.isMissingValue(pred)) {
         sums[0] += pred;
         numPreds++;
       }
     } else {
newProbs = m_Classifiers[i].distributionForInstance(instance);
for (int j = 0; j < newProbs.length; j++)
  sums[j] += newProbs[j];
     }
   }
   if (instance.classAttribute().isNumeric() == true) {
     if (numPreds == 0) {
       sums[0] = Utils.missingValue();
     } else {
       sums[0] /= numPreds;
     }
     return sums;
   } else if (Utils.eq(Utils.sum(sums), 0)) {
     return sums;
   } else {
     Utils.normalize(sums);
     return sums;
   }
 }
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:41,代码来源:RandomCommittee.java

示例11: buildTree

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Builds the tree structure with hold out set
 * 
 * @param train the data for which the tree structure is to be generated.
 * @param test the test data for potential pruning
 * @param keepData is training Data to be kept?
 * @throws Exception if something goes wrong
 */
public void buildTree(Instances train, Instances test, boolean keepData)
  throws Exception {

  Instances[] localTrain, localTest;
  int i;

  if (keepData) {
    m_train = train;
  }
  m_isLeaf = false;
  m_isEmpty = false;
  m_sons = null;
  m_localModel = m_toSelectModel.selectModel(train, test);
  m_test = new Distribution(test, m_localModel);
  if (m_localModel.numSubsets() > 1) {
    localTrain = m_localModel.split(train);
    localTest = m_localModel.split(test);
    train = null;
    test = null;
    m_sons = new ClassifierTree[m_localModel.numSubsets()];
    for (i = 0; i < m_sons.length; i++) {
      m_sons[i] = getNewTree(localTrain[i], localTest[i]);
      localTrain[i] = null;
      localTest[i] = null;
    }
  } else {
    m_isLeaf = true;
    if (Utils.eq(train.sumOfWeights(), 0)) {
      m_isEmpty = true;
    }
    train = null;
    test = null;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:43,代码来源:ClassifierTree.java

示例12: getEstimatedErrorsForTree

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Computes estimated errors for tree.
 */
private double getEstimatedErrorsForTree() {

  if (m_isLeaf) {
    return getEstimatedErrorsForLeaf();
  } else {
    double error = 0;
    for (int i = 0; i < m_sons.length; i++) {
      if (!Utils.eq(son(i).localModel().distribution().total(), 0)) {
        error += ((C45PruneableDecList) son(i)).getEstimatedErrorsForTree();
      }
    }
    return error;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:18,代码来源:C45PruneableDecList.java

示例13: addInstWithUnknown

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Adds all instances with unknown values for given attribute, weighted
 * according to frequency of instances in each bag.
 * 
 * @exception Exception if something goes wrong
 */
public final void addInstWithUnknown(Instances source, int attIndex)
  throws Exception {

  double[] probs;
  double weight, newWeight;
  int classIndex;
  Instance instance;
  int j;

  probs = new double[m_perBag.length];
  for (j = 0; j < m_perBag.length; j++) {
    if (Utils.eq(totaL, 0)) {
      probs[j] = 1.0 / probs.length;
    } else {
      probs[j] = m_perBag[j] / totaL;
    }
  }
  Enumeration<Instance> enu = source.enumerateInstances();
  while (enu.hasMoreElements()) {
    instance = enu.nextElement();
    if (instance.isMissing(attIndex)) {
      classIndex = (int) instance.classValue();
      weight = instance.weight();
      m_perClass[classIndex] = m_perClass[classIndex] + weight;
      totaL = totaL + weight;
      for (j = 0; j < m_perBag.length; j++) {
        newWeight = probs[j] * weight;
        m_perClassPerBag[j][classIndex] = m_perClassPerBag[j][classIndex]
          + newWeight;
        m_perBag[j] = m_perBag[j] + newWeight;
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:41,代码来源:Distribution.java

示例14: prob

import weka.core.Utils; //导入方法依赖的package包/类
/**
 * Returns relative frequency of class over all bags.
 */
public final double prob(int classIndex) {

  if (!Utils.eq(totaL, 0)) {
    return m_perClass[classIndex] / totaL;
  } else {
    return 0;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:12,代码来源:Distribution.java

示例15: getEstimatedErrorsForDistribution

import weka.core.Utils; //导入方法依赖的package包/类
/**
  * Computes estimated errors for leaf.
  * 
  * @param theDistribution the distribution to use
  * @return the estimated errors
  */
 private double getEstimatedErrorsForDistribution(Distribution 
					   theDistribution){

   if (Utils.eq(theDistribution.total(),0))
     return 0;
   else
     return theDistribution.numIncorrect()+
Stats.addErrs(theDistribution.total(),
	      theDistribution.numIncorrect(),m_CF);
 }
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:17,代码来源:C45PruneableClassifierTree.java


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