本文整理汇总了Java中weka.core.FastVector.removeElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java FastVector.removeElementAt方法的具体用法?Java FastVector.removeElementAt怎么用?Java FastVector.removeElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.FastVector
的用法示例。
在下文中一共展示了FastVector.removeElementAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDecisionList
import weka.core.FastVector; //导入方法依赖的package包/类
/**
* Generates a new rule for the decision list.
* and classifies the new example
* @param random random number generator
* @param example example used to update decision list
* @return the classified example
* @throws Exception if dataset format not defined
*/
private Instance updateDecisionList(Random random, Instance example)
throws Exception {
FastVector TestList;
Instances format = getDatasetFormat();
if (format == null)
throw new Exception("Dataset format not defined.");
TestList = generateTestList(random, example);
int maxSize = getMaxRuleSize() < TestList.size() ?
getMaxRuleSize() : TestList.size();
int ruleSize = ((int) (random.nextDouble() *
(double) (maxSize - getMinRuleSize())))
+ getMinRuleSize();
RuleList newRule = new RuleList();
for (int i=0; i < ruleSize; i++) {
int testIndex = (int) (random.nextDouble() * (double) TestList.size());
Test test = (Test) TestList.elementAt(testIndex);
newRule.addTest(test);
TestList.removeElementAt(testIndex);
}
double newClassValue = 0.0;
if (m_DecisionList.size() > 0) {
RuleList r = (RuleList)(m_DecisionList.lastElement());
double oldClassValue = (double)
(r.getClassValue());
newClassValue = (double)((int)oldClassValue + 1)
% getNumClasses();
}
newRule.setClassValue(newClassValue);
m_DecisionList.addElement(newRule);
example = (Instance)example.copy();
example.setDataset(format);
example.setClassValue(newClassValue);
return example;
}