本文整理了Java中weka.core.Utils.smOrEq()
方法的一些代码示例,展示了Utils.smOrEq()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.smOrEq()
方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:smOrEq
[英]Tests if a is smaller or equal to b.
[中]测试a是否小于或等于b。
代码示例来源:origin: nz.ac.waikato.cms.weka/conjunctiveRule
/**
* Function used to calculate the weighted mean squared error, i.e.,
* sum[x-avg(x)]^2 based on the given elements of the formula:
* meanSquaredError = sum(Wi*Xi^2) - (sum(WiXi))^2/sum(Wi)
*
* @param weightedSq sum(Wi*Xi^2)
* @param weightedValue sum(WiXi)
* @param sum sum of weights
* @return the weighted mean-squared error
*/
protected double wtMeanSqErr(double weightedSq, double weightedValue,
double sum) {
if (Utils.smOrEq(sum, 1.0E-6)) {
return 0;
}
return (weightedSq - (weightedValue * weightedValue) / sum);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Computes chi-value for one cell in a contingency table.
*
* @param freq the observed frequency in the cell
* @param expected the expected frequency in the cell
* @return the chi-value for that cell; 0 if the expected value is
* too close to zero
*/
private static double chiCell(double freq, double expected,
boolean yates){
// Cell in empty row and column?
if (Utils.smOrEq(expected, 0)) {
return 0;
}
// Compute difference between observed and expected value
double diff = Math.abs(freq - expected);
if (yates) {
// Apply Yates' correction if wanted
diff -= 0.5;
// The difference should never be negative
if (diff < 0) {
diff = 0;
}
}
// Return chi-value for the cell
return (diff * diff / expected);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Computes chi-value for one cell in a contingency table.
*
* @param freq the observed frequency in the cell
* @param expected the expected frequency in the cell
* @return the chi-value for that cell; 0 if the expected value is
* too close to zero
*/
private static double chiCell(double freq, double expected,
boolean yates){
// Cell in empty row and column?
if (Utils.smOrEq(expected, 0)) {
return 0;
}
// Compute difference between observed and expected value
double diff = Math.abs(freq - expected);
if (yates) {
// Apply Yates' correction if wanted
diff -= 0.5;
// The difference should never be negative
if (diff < 0) {
diff = 0;
}
}
// Return chi-value for the cell
return (diff * diff / expected);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/conjunctiveRule
/**
* Function used to calculate the entropy of given vector of values entropy
* = (1/sum)*{-sigma[i=1..P](Xi*log2(Xi)) + sum*log2(sum)} where P is the
* length of the vector
*
* @param value the given vector of values
* @param sum the sum of the given values. It's provided just for
* efficiency.
* @return the entropy
*/
protected double entropy(double[] value, double sum) {
if (Utils.smOrEq(sum, 1.0E-6)) {
return 0;
}
double entropy = 0;
for (int i = 0; i < value.length; i++) {
if (!Utils.eq(value[i], 0)) {
entropy -= value[i] * Utils.log2(value[i]);
}
}
entropy += sum * Utils.log2(sum);
entropy /= sum;
return entropy;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Prunes the end of the rule.
*/
protected void pruneEnd() throws Exception {
double errorsLeaf, errorsTree;
errorsTree = errorsForTree();
errorsLeaf = errorsForLeaf();
if (Utils.smOrEq(errorsLeaf, errorsTree)) {
m_isLeaf = true;
m_sons = null;
m_localModel = new NoSplit(localModel().distribution());
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Prunes the end of the rule.
*/
protected void pruneEnd() {
double errorsLeaf, errorsTree;
errorsTree = getEstimatedErrorsForTree();
errorsLeaf = getEstimatedErrorsForLeaf();
if (Utils.smOrEq(errorsLeaf, errorsTree + 0.1)) { // +0.1 as in C4.5
m_isLeaf = true;
m_sons = null;
m_localModel = new NoSplit(localModel().distribution());
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Prunes the end of the rule.
*/
protected void pruneEnd() throws Exception {
double errorsLeaf, errorsTree;
errorsTree = errorsForTree();
errorsLeaf = errorsForLeaf();
if (Utils.smOrEq(errorsLeaf, errorsTree)) {
m_isLeaf = true;
m_sons = null;
m_localModel = new NoSplit(localModel().distribution());
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Prunes the end of the rule.
*/
protected void pruneEnd() {
double errorsLeaf, errorsTree;
errorsTree = getEstimatedErrorsForTree();
errorsLeaf = getEstimatedErrorsForLeaf();
if (Utils.smOrEq(errorsLeaf, errorsTree + 0.1)) { // +0.1 as in C4.5
m_isLeaf = true;
m_sons = null;
m_localModel = new NoSplit(localModel().distribution());
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
public final int whichSubset(Instance instance)
throws Exception {
if (instance.isMissing(m_attIndex))
return -1;
else{
if (instance.attribute(m_attIndex).isNominal())
return (int)instance.value(m_attIndex);
else
if (Utils.smOrEq(instance.value(m_attIndex),m_splitPoint))
return 0;
else
return 1;
}
}
代码示例来源:origin: Waikato/weka-trunk
public final int whichSubset(Instance instance)
throws Exception {
if (instance.isMissing(m_attIndex))
return -1;
else{
if (instance.attribute(m_attIndex).isNominal())
return (int)instance.value(m_attIndex);
else
if (Utils.smOrEq(instance.value(m_attIndex),m_splitPoint))
return 0;
else
return 1;
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/conjunctiveRule
/**
* Whether the instance is covered by this antecedent
*
* @param inst the instance in question
* @return the boolean value indicating whether the instance is covered by
* this antecedent
*/
@Override
public boolean isCover(Instance inst) {
boolean isCover = false;
if (!inst.isMissing(att)) {
if (Utils.eq(value, 0)) {
if (Utils.smOrEq(inst.value(att), splitPoint)) {
isCover = true;
}
} else if (Utils.gr(inst.value(att), splitPoint)) {
isCover = true;
}
}
return isCover;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Prunes a tree.
*
* @throws Exception if tree can't be pruned successfully
*/
public void prune() throws Exception {
if (!m_isLeaf) {
// Prune all subtrees.
for (int i = 0; i < m_sons.length; i++)
son(i).prune();
// Decide if leaf is best choice.
if (Utils.smOrEq(errorsForLeaf(),errorsForTree())) {
// Free son Trees
m_sons = null;
m_isLeaf = true;
// Get NoSplit Model for node.
m_localModel = new NoSplit(localModel().distribution());
}
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Prunes a tree.
*
* @throws Exception if tree can't be pruned successfully
*/
public void prune() throws Exception {
if (!m_isLeaf) {
// Prune all subtrees.
for (int i = 0; i < m_sons.length; i++)
son(i).prune();
// Decide if leaf is best choice.
if (Utils.smOrEq(errorsForLeaf(),errorsForTree())) {
// Free son Trees
m_sons = null;
m_isLeaf = true;
// Get NoSplit Model for node.
m_localModel = new NoSplit(localModel().distribution());
}
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
if (Utils.smOrEq(errorsLeaf,errorsTree+0.1) &&
Utils.smOrEq(errorsLeaf,errorsLargestBranch+0.1)){
if (Utils.smOrEq(errorsLargestBranch,errorsTree+0.1)){
largestBranch = son(indexOfLargestBranch);
m_sons = largestBranch.m_sons;
代码示例来源:origin: Waikato/weka-trunk
if (Utils.smOrEq(errorsLeaf,errorsTree+0.1) &&
Utils.smOrEq(errorsLeaf,errorsLargestBranch+0.1)){
if (Utils.smOrEq(errorsLargestBranch,errorsTree+0.1)){
largestBranch = son(indexOfLargestBranch);
m_sons = largestBranch.m_sons;
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
if (Utils.smOrEq(minSplit, m_minNoObj)) {
minSplit = m_minNoObj;
} else if (Utils.gr(minSplit, 25)) {
m_infoGain = m_infoGain - (Utils.log2(m_index) / m_sumOfWeights);
if (Utils.smOrEq(m_infoGain, 0)) {
return;
代码示例来源:origin: Waikato/weka-trunk
if (Utils.smOrEq(minSplit, m_minNoObj)) {
minSplit = m_minNoObj;
} else if (Utils.gr(minSplit, 25)) {
m_infoGain = m_infoGain - (Utils.log2(index) / m_sumOfWeights);
if (Utils.smOrEq(m_infoGain, 0)) {
return;
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
if (Utils.smOrEq(minSplit, m_minNoObj)) {
minSplit = m_minNoObj;
} else if (Utils.gr(minSplit, 25)) {
m_infoGain = m_infoGain - (Utils.log2(index) / m_sumOfWeights);
if (Utils.smOrEq(m_infoGain, 0)) {
return;
代码示例来源:origin: Waikato/weka-trunk
estimated /= (localModel().distribution().perBag(i) * ContingencyTables.log2);
if (Utils.smOrEq(estimated, 0)) {
return i;
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
estimated /= (localModel().distribution().perBag(i) * ContingencyTables.log2);
if (Utils.smOrEq(estimated, 0)) {
return i;
内容来源于网络,如有侵权,请联系作者删除!