本文整理了Java中weka.core.Utils.gr()
方法的一些代码示例,展示了Utils.gr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.gr()
方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:gr
[英]Tests if a is greater than b.
[中]测试a是否大于b。
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns number of classes actually occuring in given bag.
*/
public final int actualNumClasses(int bagIndex) {
int returnValue = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClassPerBag[bagIndex][i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns number of classes actually occuring in distribution.
*/
public final int actualNumClasses() {
int returnValue = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClass[i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns number of non-empty bags of distribution.
*/
public final int actualNumBags() {
int returnValue = 0;
int i;
for (i = 0; i < m_perBag.length; i++) {
if (Utils.gr(m_perBag[i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns number of non-empty bags of distribution.
*/
public final int actualNumBags() {
int returnValue = 0;
int i;
for (i = 0; i < m_perBag.length; i++) {
if (Utils.gr(m_perBag[i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns number of classes actually occuring in distribution.
*/
public final int actualNumClasses() {
int returnValue = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClass[i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns number of classes actually occuring in given bag.
*/
public final int actualNumClasses(int bagIndex) {
int returnValue = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClassPerBag[bagIndex][i], 0)) {
returnValue++;
}
}
return returnValue;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns class with highest frequency over all bags.
*/
public final int maxClass() {
double maxCount = 0;
int maxIndex = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClass[i], maxCount)) {
maxCount = m_perClass[i];
maxIndex = i;
}
}
return maxIndex;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns class with highest frequency over all bags.
*/
public final int maxClass() {
double maxCount = 0;
int maxIndex = 0;
int i;
for (i = 0; i < m_perClass.length; i++) {
if (Utils.gr(m_perClass[i], maxCount)) {
maxCount = m_perClass[i];
maxIndex = i;
}
}
return maxIndex;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns relative frequency of class for given bag.
*/
public final double prob(int classIndex, int intIndex) {
if (Utils.gr(m_perBag[intIndex], 0)) {
return m_perClassPerBag[intIndex][classIndex] / m_perBag[intIndex];
} else {
return prob(classIndex);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns relative frequency of class for given bag.
*/
public final double laplaceProb(int classIndex, int intIndex) {
if (Utils.gr(m_perBag[intIndex], 0)) {
return (m_perClassPerBag[intIndex][classIndex] + 1.0)
/ (m_perBag[intIndex] + m_perClass.length);
} else {
return laplaceProb(classIndex);
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns relative frequency of class for given bag.
*/
public final double prob(int classIndex, int intIndex) {
if (Utils.gr(m_perBag[intIndex], 0)) {
return m_perClassPerBag[intIndex][classIndex] / m_perBag[intIndex];
} else {
return prob(classIndex);
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns relative frequency of class for given bag.
*/
public final double laplaceProb(int classIndex, int intIndex) {
if (Utils.gr(m_perBag[intIndex], 0)) {
return (m_perClassPerBag[intIndex][classIndex] + 1.0)
/ (m_perBag[intIndex] + m_perClass.length);
} else {
return laplaceProb(classIndex);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Returns the log-odds for a given probabilitiy.
*
* @param prob the probabilitiy
*
* @return the log-odds after the probability has been mapped to [Utils.SMALL,
* 1-Utils.SMALL]
*/
public static/* @pure@ */double probToLogOdds(double prob) {
if (gr(prob, 1) || (sm(prob, 0))) {
throw new IllegalArgumentException("probToLogOdds: probability must "
+ "be in [0,1] " + prob);
}
double p = SMALL + (1.0 - 2 * SMALL) * prob;
return Math.log(p / (1 - p));
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Returns the log-odds for a given probabilitiy.
*
* @param prob the probabilitiy
*
* @return the log-odds after the probability has been mapped to [Utils.SMALL,
* 1-Utils.SMALL]
*/
public static/* @pure@ */double probToLogOdds(double prob) {
if (gr(prob, 1) || (sm(prob, 0))) {
throw new IllegalArgumentException("probToLogOdds: probability must "
+ "be in [0,1] " + prob);
}
double p = SMALL + (1.0 - 2 * SMALL) * prob;
return Math.log(p / (1 - p));
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Subset description length: <br>
* S(t,k,p) = -k*log2(p)-(n-k)log2(1-p)
*
* Details see Quilan: "MDL and categorical theories (Continued)",ML95
*
* @param t the number of elements in a known set
* @param k the number of elements in a subset
* @param p the expected proportion of subset known by recipient
* @return the subset description length
*/
public static double subsetDL(double t, double k, double p) {
double rt = Utils.gr(p, 0.0) ? (-k * Utils.log2(p)) : 0.0;
rt -= (t - k) * Utils.log2(1 - p);
return rt;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Subset description length: <br>
* S(t,k,p) = -k*log2(p)-(n-k)log2(1-p)
*
* Details see Quilan: "MDL and categorical theories (Continued)",ML95
*
* @param t the number of elements in a known set
* @param k the number of elements in a subset
* @param p the expected proportion of subset known by recipient
* @return the subset description length
*/
public static double subsetDL(double t, double k, double p) {
double rt = Utils.gr(p, 0.0) ? (-k * Utils.log2(p)) : 0.0;
rt -= (t - k) * Utils.log2(1 - p);
return rt;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Prints label for subset index of instances (eg class).
*
* @exception Exception if something goes wrong
*/
public final String dumpLabel(int index,Instances data) throws Exception {
StringBuffer text;
text = new StringBuffer();
text.append(((Instances)data).classAttribute().
value(m_distribution.maxClass(index)));
text.append(" ("+Utils.roundDouble(m_distribution.perBag(index),2));
if (Utils.gr(m_distribution.numIncorrect(index),0))
text.append("/"+Utils.roundDouble(m_distribution.numIncorrect(index),2));
text.append(")");
return text.toString();
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Prints label for subset index of instances (eg class).
*
* @exception Exception if something goes wrong
*/
public final String dumpLabel(int index,Instances data) throws Exception {
StringBuffer text;
text = new StringBuffer();
text.append(((Instances)data).classAttribute().
value(m_distribution.maxClass(index)));
text.append(" ("+Utils.roundDouble(m_distribution.perBag(index),2));
if (Utils.gr(m_distribution.numIncorrect(index),0))
text.append("/"+Utils.roundDouble(m_distribution.numIncorrect(index),2));
text.append(")");
return text.toString();
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Help method for computing the split entropy.
*/
private final double splitEnt(Distribution bags, double totalnoInst) {
double returnValue = 0;
double noUnknown;
int i;
noUnknown = totalnoInst - bags.total();
if (Utils.gr(bags.total(), 0)) {
for (i = 0; i < bags.numBags(); i++) {
returnValue = returnValue - lnFunc(bags.perBag(i));
}
returnValue = returnValue - lnFunc(noUnknown);
returnValue = returnValue + lnFunc(totalnoInst);
}
return returnValue / ContingencyTables.log2;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Help method for computing the split entropy.
*/
private final double splitEnt(Distribution bags, double totalnoInst) {
double returnValue = 0;
double noUnknown;
int i;
noUnknown = totalnoInst - bags.total();
if (Utils.gr(bags.total(), 0)) {
for (i = 0; i < bags.numBags(); i++) {
returnValue = returnValue - lnFunc(bags.perBag(i));
}
returnValue = returnValue - lnFunc(noUnknown);
returnValue = returnValue + lnFunc(totalnoInst);
}
return returnValue / ContingencyTables.log2;
}
内容来源于网络,如有侵权,请联系作者删除!