本文整理汇总了Java中weka.core.Utils.smOrEq方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.smOrEq方法的具体用法?Java Utils.smOrEq怎么用?Java Utils.smOrEq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Utils
的用法示例。
在下文中一共展示了Utils.smOrEq方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prune
import weka.core.Utils; //导入方法依赖的package包/类
/**
* 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());
}
}
}
示例2: setSplitPoint
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Sets split point to greatest value in given data smaller or equal to old
* split point. (C4.5 does this for some strange reason).
*/
public final void setSplitPoint(Instances allInstances) {
double newSplitPoint = -Double.MAX_VALUE;
double tempValue;
Instance instance;
if ((!allInstances.attribute(m_attIndex).isNominal()) && (m_numSubsets > 1)) {
Enumeration<Instance> enu = allInstances.enumerateInstances();
while (enu.hasMoreElements()) {
instance = enu.nextElement();
if (!instance.isMissing(m_attIndex)) {
tempValue = instance.value(m_attIndex);
if (Utils.gr(tempValue, newSplitPoint)
&& Utils.smOrEq(tempValue, m_splitPoint)) {
newSplitPoint = tempValue;
}
}
}
m_splitPoint = newSplitPoint;
}
}
示例3: whichSubset
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns index of subset instance is assigned to. Returns -1 if instance is
* assigned to more than one subset.
*
* @exception Exception if something goes wrong
*/
@Override
public final int whichSubset(Instance instance) throws Exception {
if (instance.isMissing(m_attIndex)) {
return -1;
} else {
if (instance.attribute(m_attIndex).isNominal()) {
if ((int) m_splitPoint == (int) instance.value(m_attIndex)) {
return 0;
} else {
return 1;
}
} else if (Utils.smOrEq(instance.value(m_attIndex), m_splitPoint)) {
return 0;
} else {
return 1;
}
}
}
示例4: setSplitPoint
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Sets split point to greatest value in given data smaller or equal to old
* split point. (C4.5 does this for some strange reason).
*/
public final void setSplitPoint(Instances allInstances) {
double newSplitPoint = -Double.MAX_VALUE;
double tempValue;
Instance instance;
if ((allInstances.attribute(m_attIndex).isNumeric()) && (m_numSubsets > 1)) {
Enumeration<Instance> enu = allInstances.enumerateInstances();
while (enu.hasMoreElements()) {
instance = enu.nextElement();
if (!instance.isMissing(m_attIndex)) {
tempValue = instance.value(m_attIndex);
if (Utils.gr(tempValue, newSplitPoint)
&& Utils.smOrEq(tempValue, m_splitPoint)) {
newSplitPoint = tempValue;
}
}
}
m_splitPoint = newSplitPoint;
}
}
示例5: whichSubset
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns index of subset instance is assigned to. Returns -1 if instance is
* assigned to more than one subset.
*
* @exception Exception if something goes wrong
*/
@Override
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;
}
}
}
示例6: whichSubset
import weka.core.Utils; //导入方法依赖的package包/类
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;
}
}
示例7: pruneEnd
import weka.core.Utils; //导入方法依赖的package包/类
/**
* 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());
}
}
示例8: pruneEnd
import weka.core.Utils; //导入方法依赖的package包/类
/**
* 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());
}
}
示例9: chooseIndex
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Method for choosing a subset to expand.
*/
public final int chooseIndex() {
int minIndex = -1;
double estimated, min = Double.MAX_VALUE;
int i, j;
for (i = 0; i < m_sons.length; i++) {
if (son(i) == null) {
if (Utils.sm(localModel().distribution().perBag(i), m_minNumObj)) {
estimated = Double.MAX_VALUE;
} else {
estimated = 0;
for (j = 0; j < localModel().distribution().numClasses(); j++) {
estimated -= m_splitCrit.lnFunc(localModel().distribution()
.perClassPerBag(i, j));
}
estimated += m_splitCrit
.lnFunc(localModel().distribution().perBag(i));
estimated /= (localModel().distribution().perBag(i) * ContingencyTables.log2);
}
if (Utils.smOrEq(estimated, 0)) {
return i;
}
if (Utils.sm(estimated, min)) {
min = estimated;
minIndex = i;
}
}
}
return minIndex;
}
示例10: prune
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Prunes a tree using C4.5's pruning procedure.
*
* @throws Exception if something goes wrong
*/
public void prune() throws Exception {
double errorsLargestBranch;
double errorsLeaf;
double errorsTree;
int indexOfLargestBranch;
C45PruneableClassifierTree largestBranch;
int i;
if (!m_isLeaf){
// Prune all subtrees.
for (i=0;i<m_sons.length;i++)
son(i).prune();
// Compute error for largest branch
indexOfLargestBranch = localModel().distribution().maxBag();
if (m_subtreeRaising) {
errorsLargestBranch = son(indexOfLargestBranch).
getEstimatedErrorsForBranch((Instances)m_train);
} else {
errorsLargestBranch = Double.MAX_VALUE;
}
// Compute error if this Tree would be leaf
errorsLeaf =
getEstimatedErrorsForDistribution(localModel().distribution());
// Compute error for the whole subtree
errorsTree = getEstimatedErrors();
// Decide if leaf is best choice.
if (Utils.smOrEq(errorsLeaf,errorsTree+0.1) &&
Utils.smOrEq(errorsLeaf,errorsLargestBranch+0.1)){
// Free son Trees
m_sons = null;
m_isLeaf = true;
// Get NoSplit Model for node.
m_localModel = new NoSplit(localModel().distribution());
return;
}
// Decide if largest branch is better choice
// than whole subtree.
if (Utils.smOrEq(errorsLargestBranch,errorsTree+0.1)){
largestBranch = son(indexOfLargestBranch);
m_sons = largestBranch.m_sons;
m_localModel = largestBranch.localModel();
m_isLeaf = largestBranch.m_isLeaf;
newDistribution(m_train);
prune();
}
}
}