本文整理匯總了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;
}