weka.core.Utils.eq()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(149)

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

Utils.eq介绍

[英]Tests if a is equal to b.
[中]测试a是否等于b。

代码示例

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

/**
 * 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;
 }
}

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

/**
 * 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;
 }
}

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

/**
 * Normalizes a given value of a numeric attribute.
 * 
 * @param x the value to be normalized
 * @param i the attribute's index
 */
private 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]);
 }
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

/**
 * 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_Min[i]) || Utils.eq(m_Max[i], m_Min[i])) {
    return 0;
  } else {
    return (x - m_Min[i]) / (m_Max[i] - m_Min[i]);
  }
}

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

/**
 * Normalizes a given value of a numeric attribute.
 * 
 * @param x the value to be normalized
 * @param i the attribute's index
 */
private 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]);
 }
}

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

/**
 * 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]);
 }
}

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

/**
 * 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]);
 }
}

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

/**
 * 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]);
 }
}

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

/**
 * 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]);
 }
}

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

/**
 * 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]);
 }
}

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

/**
 * CalcLogLoss.
 * @param    R    y
 * @param    P    p(y==1)
 * @param    C    limit
 * @return     Log loss
 */
public static double calcLogLoss(double R, double P, double C) {
  // base 2 ?
  double ans = Math.min(Utils.eq(R,P) ? 0.0 : -( (R * Math.log(P)) + ((1.0 - R) * Math.log(1.0 - P)) ),C);
  return (Double.isNaN(ans) ? 0.0 : ans);
}

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

/**
 * L_LogLoss - the log loss between real-valued confidence rpred and true prediction y.
 * @param    y        label
 * @param    rpred    prediction (confidence)
 * @param    C        limit (maximum loss of log(C))
 * @return     Log loss
 */
public static double L_LogLoss(double y, double rpred, double C) {
  if (y == -1) {
    return 0.0;
  }
// base 2 ?
double ans = Math.min(Utils.eq(y,rpred) ? 0.0 : -( (y * Math.log(rpred)) + ((1.0 - y) * Math.log(1.0 - rpred)) ),C);
  return (Double.isNaN(ans) ? 0.0 : ans);
}

代码示例来源:origin: net.sf.meka/meka

/**
 * L_LogLoss - the log loss between real-valued confidence rpred and true prediction y.
 * @param    y        label
 * @param    rpred    prediction (confidence)
 * @param    C        limit (maximum loss of log(C))
 * @return     Log loss
 */
public static double L_LogLoss(double y, double rpred, double C) {
  if (y == -1) {
    return 0.0;
  }
// base 2 ?
double ans = Math.min(Utils.eq(y,rpred) ? 0.0 : -( (y * Math.log(rpred)) + ((1.0 - y) * Math.log(1.0 - rpred)) ),C);
  return (Double.isNaN(ans) ? 0.0 : ans);
}

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

@Override
Predicate.Eval evaluate(double[] input, double value, int fieldIndex) {
 return Predicate.booleanToEval(
  Utils.isMissingValue(input[fieldIndex]),
  weka.core.Utils.eq(input[fieldIndex], value));
}

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

/**
 * Prints this antecedent
 * 
 * @return a textual description of this antecedent
 */
@Override
public String toString() {
 String symbol = Utils.eq(value, 0.0) ? " <= " : " > ";
 return (att.name() + symbol + Utils.doubleToString(splitPoint, 6));
}

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

@Override
Predicate.Eval evaluate(double[] input, double value, int fieldIndex) {
 return Predicate.booleanToEval(
  Utils.isMissingValue(input[fieldIndex]),
  weka.core.Utils.eq(input[fieldIndex], value));
}

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

/**
 * This method is a straightforward implementation of the information gain
 * criterion for the given distribution.
 */
@Override
public final double splitCritValue(Distribution bags) {
 double numerator;
 numerator = oldEnt(bags) - newEnt(bags);
 // Splits with no gain are useless.
 if (Utils.eq(numerator, 0)) {
  return Double.MAX_VALUE;
 }
 // We take the reciprocal value because we want to minimize the
 // splitting criterion's value.
 return bags.total() / numerator;
}

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

/**
 * 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);
}

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

/**
 * 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);
}

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

public void testTypical() {
 Instances result = useFilter();
 // Number of attributes and instances shouldn't change
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 assertEquals(m_Instances.numInstances(),  result.numInstances());
 // Check conversion is OK
 for (int j = 0; j < result.numAttributes(); j++) {
  if (result.attribute(j).isNumeric()) {
 double mean = result.meanOrMode(j);
 assertTrue("Mean should be 0", Utils.eq(mean, 0));
 double stdDev = Math.sqrt(result.variance(j));
 assertTrue("StdDev should be 1 (or 0)", 
     Utils.eq(stdDev, 0) || Utils.eq(stdDev, 1));
  }
 }
}

相关文章

微信公众号

最新文章

更多