本文整理匯總了Java中weka.core.FastVector.elementAt方法的典型用法代碼示例。如果您正苦於以下問題:Java FastVector.elementAt方法的具體用法?Java FastVector.elementAt怎麽用?Java FastVector.elementAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.core.FastVector
的用法示例。
在下文中一共展示了FastVector.elementAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: input
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Input an instance for filtering. Filter requires all
* training instances be read before producing output.
*
* @param instance the input instance.
* @return true if the filtered instance may now be
* collected with output().
* @throws IllegalStateException if no input structure has been defined.
*/
public boolean input(Instance instance) throws Exception {
if (getInputFormat() == null) {
throw new IllegalStateException("No input instance format defined");
}
if (m_NewBatch) {
resetQueue();
m_NewBatch = false;
}
if (isFirstBatchDone()) {
FastVector fv = new FastVector();
int firstCopy = convertInstancewoDocNorm(instance, fv);
Instance inst = (Instance)fv.elementAt(0);
if (m_filterType != FILTER_NONE) {
normalizeInstance(inst, firstCopy);
}
push(inst);
return true;
} else {
bufferInput(instance);
return false;
}
}
示例2: spaceHorizontal
import weka.core.FastVector; //導入方法依賴的package包/類
/** space out set of nodes evenly between left and right most node in the list
* @param nodes list of indexes of nodes to space out
*/
public void spaceHorizontal(FastVector nodes) {
// update undo stack
if (m_bNeedsUndoAction) {
addUndoAction(new spaceHorizontalAction(nodes));
}
int nMinX = -1;
int nMaxX = -1;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nX = getPositionX((Integer) nodes.elementAt(iNode));
if (nX < nMinX || iNode == 0) {
nMinX = nX;
}
if (nX > nMaxX || iNode == 0) {
nMaxX = nX;
}
}
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nNode = (Integer) nodes.elementAt(iNode);
m_nPositionX.setElementAt((int) (nMinX + iNode * (nMaxX - nMinX) / (nodes.size() - 1.0)), nNode);
}
}
示例3: DelValueAction
import weka.core.FastVector; //導入方法依賴的package包/類
DelValueAction(int nTargetNode, String sValue) {
try {
m_nTargetNode = nTargetNode;
m_sValue = sValue;
m_att = m_Instances.attribute(nTargetNode);
SerializedObject so = new SerializedObject(m_Distributions[nTargetNode]);
m_CPT = (Estimator[]) so.getObject();
;
m_children = new FastVector();
for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
if (m_ParentSets[iNode].contains(nTargetNode)) {
m_children.addElement(iNode);
}
}
m_childAtts = new Estimator[m_children.size()][];
for (int iChild = 0; iChild < m_children.size(); iChild++) {
int nChild = (Integer) m_children.elementAt(iChild);
m_childAtts[iChild] = m_Distributions[nChild];
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getDefinition
import weka.core.FastVector; //導入方法依賴的package包/類
Element getDefinition(Document doc, String sName) throws Exception {
//NodeList nodelist = selectNodeList(doc, "//DEFINITION[normalize-space(FOR/text())=\"" + sName + "\"]");
NodeList nodelist = doc.getElementsByTagName("DEFINITION");
for (int iNode = 0; iNode < nodelist.getLength(); iNode++) {
Node node = nodelist.item(iNode);
FastVector list = selectElements(node, "FOR");
if (list.size() > 0) {
Node forNode = (Node) list.elementAt(0);
if (getContent((Element) forNode).trim().equals(sName)) {
return (Element) node;
}
}
}
throw new Exception("Could not find definition for ((" + sName + "))");
}
示例5: alignRight
import weka.core.FastVector; //導入方法依賴的package包/類
/** align set of nodes with the right most node in the list
* @param nodes list of indexes of nodes to align
*/
public void alignRight(FastVector nodes) {
// update undo stack
if (m_bNeedsUndoAction) {
addUndoAction(new alignRightAction(nodes));
}
int nMaxX = -1;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nX = getPositionX((Integer) nodes.elementAt(iNode));
if (nX > nMaxX || iNode == 0) {
nMaxX = nX;
}
}
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nNode = (Integer) nodes.elementAt(iNode);
m_nPositionX.setElementAt(nMaxX, nNode);
}
}
示例6: rmCoveredBySuccessives
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Static utility function to count the data covered by the
* rules after the given index in the given rules, and then
* remove them. It returns the data not covered by the
* successive rules.
*
* @param data the data to be processed
* @param rules the ruleset
* @param index the given index
* @return the data after processing
*/
public static Instances rmCoveredBySuccessives(Instances data, FastVector rules, int index){
Instances rt = new Instances(data, 0);
for(int i=0; i < data.numInstances(); i++){
Instance datum = data.instance(i);
boolean covered = false;
for(int j=index+1; j<rules.size();j++){
Rule rule = (Rule)rules.elementAt(j);
if(rule.covers(datum)){
covered = true;
break;
}
}
if(!covered)
rt.add(datum);
}
return rt;
}
示例7: centerHorizontal
import weka.core.FastVector; //導入方法依賴的package包/類
/** center set of nodes half way between left and right most node in the list
* @param nodes list of indexes of nodes to center
*/
public void centerHorizontal(FastVector nodes) {
// update undo stack
if (m_bNeedsUndoAction) {
addUndoAction(new centerHorizontalAction(nodes));
}
int nMinY = -1;
int nMaxY = -1;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nY = getPositionY((Integer) nodes.elementAt(iNode));
if (nY < nMinY || iNode == 0) {
nMinY = nY;
}
if (nY > nMaxY || iNode == 0) {
nMaxY = nY;
}
}
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nNode = (Integer) nodes.elementAt(iNode);
m_nPositionY.setElementAt((nMinY + nMaxY) / 2, nNode);
}
}
示例8: deleteItemSets
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Deletes all item sets that don't have minimum support and have more than maximum support
* @return the reduced set of item sets
* @param maxSupport the maximum support
* @param itemSets the set of item sets to be pruned
* @param minSupport the minimum number of transactions to be covered
*/
public static FastVector deleteItemSets(FastVector itemSets,
int minSupport,
int maxSupport) {
FastVector newVector = new FastVector(itemSets.size());
for (int i = 0; i < itemSets.size(); i++) {
LabeledItemSet current = (LabeledItemSet)itemSets.elementAt(i);
if ((current.m_ruleSupCounter >= minSupport)
&& (current.m_ruleSupCounter <= maxSupport))
newVector.addElement(current);
}
return newVector;
}
示例9: getHashtable
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Return a hashtable filled with the given item sets.
*
* @param itemSets the set of item sets to be used for filling the hash table
* @param initialSize the initial size of the hashtable
* @return the generated hashtable
*/
public static Hashtable getHashtable(FastVector itemSets, int initialSize) {
Hashtable hashtable = new Hashtable(initialSize);
for (int i = 0; i < itemSets.size(); i++) {
LabeledItemSet current = (LabeledItemSet)itemSets.elementAt(i);
hashtable.put(current, new Integer(current.m_classLabel));
}
return hashtable;
}
示例10: pruneItemSets
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Prunes a set of (k)-item sets using the given (k-1)-item sets.
*
* @param toPrune the set of (k)-item sets to be pruned
* @param kMinusOne the (k-1)-item sets to be used for pruning
* @return the pruned set of item sets
*/
public static FastVector pruneItemSets(FastVector toPrune, Hashtable kMinusOne){
FastVector newVector = new FastVector(toPrune.size());
int help, j;
for (int i = 0; i < toPrune.size(); i++) {
LabeledItemSet current = (LabeledItemSet)toPrune.elementAt(i);
for (j = 0; j < current.m_items.length; j++){
if (current.m_items[j] != -1) {
help = current.m_items[j];
current.m_items[j] = -1;
if(kMinusOne.get(current) != null && (current.m_classLabel == (((Integer)kMinusOne.get(current)).intValue())))
current.m_items[j] = help;
else{
current.m_items[j] = help;
break;
}
}
}
if (j == current.m_items.length)
newVector.addElement(current);
}
return newVector;
}
示例11: alignAction
import weka.core.FastVector; //導入方法依賴的package包/類
alignAction(FastVector nodes) {
m_nodes = new FastVector(nodes.size());
m_posX = new FastVector(nodes.size());
m_posY = new FastVector(nodes.size());
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nNode = (Integer) nodes.elementAt(iNode);
m_nodes.addElement(nNode);
m_posX.addElement(getPositionX(nNode));
m_posY.addElement(getPositionY(nNode));
}
}
示例12: getHashtable
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Return a hashtable filled with the given item sets.
*
* @param itemSets the set of item sets to be used for filling the hash table
* @param initialSize the initial size of the hashtable
* @return the generated hashtable
*/
public static Hashtable getHashtable(FastVector itemSets, int initialSize) {
Hashtable hashtable = new Hashtable(initialSize);
for (int i = 0; i < itemSets.size(); i++) {
ItemSet current = (ItemSet)itemSets.elementAt(i);
hashtable.put(current, new Integer(current.m_counter));
}
return hashtable;
}
示例13: saveVisibleInstances
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Save the currently visible set of instances to a file
*/
private void saveVisibleInstances() {
FastVector plots = m_plot.m_plot2D.getPlots();
if (plots != null) {
PlotData2D master = (PlotData2D)plots.elementAt(0);
Instances saveInsts = new Instances(master.getPlotInstances());
for (int i = 1; i < plots.size(); i++) {
PlotData2D temp = (PlotData2D)plots.elementAt(i);
Instances addInsts = temp.getPlotInstances();
for (int j = 0; j < addInsts.numInstances(); j++) {
saveInsts.add(addInsts.instance(j));
}
}
try {
int returnVal = m_FileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File sFile = m_FileChooser.getSelectedFile();
if (!sFile.getName().toLowerCase().
endsWith(Instances.FILE_EXTENSION)) {
sFile = new File(sFile.getParent(), sFile.getName()
+ Instances.FILE_EXTENSION);
}
File selected = sFile;
Writer w = new BufferedWriter(new FileWriter(selected));
w.write(saveInsts.toString());
w.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
示例14: getProbabilities
import weka.core.FastVector; //導入方法依賴的package包/類
/**
*
* @param predictions the predictions to use
* @param classIndex the class index
* @return the probabilities
*/
private double [] getProbabilities(FastVector predictions, int classIndex) {
// sort by predicted probability of the desired class.
double [] probs = new double [predictions.size()];
for (int i = 0; i < probs.length; i++) {
NominalPrediction pred = (NominalPrediction)predictions.elementAt(i);
probs[i] = pred.distribution()[classIndex];
}
return probs;
}
示例15: getMargins
import weka.core.FastVector; //導入方法依賴的package包/類
/**
* Pulls all the margin values out of a vector of NominalPredictions.
*
* @param predictions a FastVector containing NominalPredictions
* @return an array of margin values.
*/
private double [] getMargins(FastVector predictions) {
// sort by predicted probability of the desired class.
double [] margins = new double [predictions.size()];
for (int i = 0; i < margins.length; i++) {
NominalPrediction pred = (NominalPrediction)predictions.elementAt(i);
margins[i] = pred.margin();
}
return margins;
}