当前位置: 首页>>代码示例>>Java>>正文


Java FastVector.addElement方法代码示例

本文整理汇总了Java中weka.core.FastVector.addElement方法的典型用法代码示例。如果您正苦于以下问题:Java FastVector.addElement方法的具体用法?Java FastVector.addElement怎么用?Java FastVector.addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.core.FastVector的用法示例。


在下文中一共展示了FastVector.addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeHeader

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * generates the header
 * 
 * @return the header
 */
private Instances makeHeader() {

  FastVector fv = new FastVector();
  fv.addElement(new Attribute(TRUE_POS_NAME));
  fv.addElement(new Attribute(FALSE_NEG_NAME));
  fv.addElement(new Attribute(FALSE_POS_NAME));
  fv.addElement(new Attribute(TRUE_NEG_NAME));
  fv.addElement(new Attribute(FP_RATE_NAME));
  fv.addElement(new Attribute(TP_RATE_NAME));
  fv.addElement(new Attribute(PRECISION_NAME));
  fv.addElement(new Attribute(RECALL_NAME));
  fv.addElement(new Attribute(FALLOUT_NAME));
  fv.addElement(new Attribute(FMEASURE_NAME));
  fv.addElement(new Attribute(SAMPLE_SIZE_NAME));
  fv.addElement(new Attribute(LIFT_NAME));
  fv.addElement(new Attribute(THRESHOLD_NAME));      
  return new Instances(RELATION_NAME, fv, 100);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:24,代码来源:ThresholdCurve.java

示例2: setInputFormat

import weka.core.FastVector; //导入方法依赖的package包/类
/**
  * Sets the format of the input instances.
  *
  * @param instanceInfo an Instances object containing the input instance
  * structure (any instances contained in the object are ignored - only the
  * structure is required).
  * @return true if the outputFormat may be collected immediately
  * @throws Exception if a problem occurs setting the input format
  */
 public boolean setInputFormat(Instances instanceInfo) throws Exception {
   super.setInputFormat(instanceInfo);
   
   FastVector attributes = new FastVector();
   int outputClass = -1;
   m_SelectedAttributes = determineIndices(instanceInfo.numAttributes());
   for (int i = 0; i < m_SelectedAttributes.length; i++) {
     int current = m_SelectedAttributes[i];
     if (instanceInfo.classIndex() == current) {
outputClass = attributes.size();
     }
     Attribute keep = (Attribute)instanceInfo.attribute(current).copy();
     attributes.addElement(keep);
   }
   
   initInputLocators(instanceInfo, m_SelectedAttributes);

   Instances outputFormat = new Instances(instanceInfo.relationName(),
				   attributes, 0); 
   outputFormat.setClassIndex(outputClass);
   setOutputFormat(outputFormat);
   
   return true;
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:34,代码来源:Reorder.java

示例3: canEstimate

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Checks basic estimation of one attribute of the scheme, for simple non-troublesome
 * datasets.
 *
 * @param attrTypes the types the estimator can work with
 * @param classType the class type (NOMINAL, NUMERIC, etc.)
 * @return index 0 is true if the test was passed, index 1 is true if test 
 *         was acceptable
 */
protected boolean[] canEstimate(AttrTypes attrTypes, boolean supervised, int classType) {
  
// supervised is ignored, no supervised estimators used yet
  
  print("basic estimation");
  printAttributeSummary(attrTypes, classType);
  print("...");
  FastVector accepts = new FastVector();
  accepts.addElement("nominal");
  accepts.addElement("numeric");
  accepts.addElement("string");
  accepts.addElement("date");
  accepts.addElement("relational");
  accepts.addElement("not in classpath");
  int numTrain = getNumInstances(), numTest = getNumInstances(), 
  numClasses = 2, missingLevel = 0;
  boolean attributeMissing = false, classMissing = false;
  int numAtts = 1, attrIndex = 0;

  return runBasicTest(attrTypes, numAtts, attrIndex,
	classType, 
	missingLevel, attributeMissing, classMissing,
	numTrain, numTest, numClasses, 
	accepts);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:35,代码来源:CheckEstimator.java

示例4: AttributePanel

import weka.core.FastVector; //导入方法依赖的package包/类
/**
  * This constructs an attributePanel.
  */
 public AttributePanel(Color background) {
   m_backgroundColor = background;
   
   setProperties();
   this.setBackground(Color.blue);
   setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);
   m_colorList = new FastVector(10);

   for (int noa = m_colorList.size(); noa < 10; noa++) {
     Color pc = m_DefaultColors[noa % 10];
     int ija =  noa / 10;
     ija *= 2; 
     for (int j=0;j<ija;j++) {
pc = pc.darker();
     }
     
     m_colorList.addElement(pc);
   }
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:23,代码来源:AttributePanel.java

示例5: buildAttribInstances

import weka.core.FastVector; //导入方法依赖的package包/类
public TrialInstances buildAttribInstances(InferenceRule ir, List allVars) {
    Collection allAttribs = VarToAttribMap.convert(allVars, ir);
    if (TRACE > 1) out.println("Attribs: "+allAttribs);
    FastVector attributes = new FastVector();
    WekaInterface.addAllPairs(attributes, allAttribs);
    attributes.addElement(new weka.core.Attribute("score"));
    int capacity = 30;
    TrialInstances data = new TrialInstances("Attribute Ordering Constraints", attributes, capacity);
    if (allAttribs.size() <= 1) return data;
    for (Iterator i = allTrials.iterator(); i.hasNext();) {
        EpisodeCollection tc2 = (EpisodeCollection) i.next();
        InferenceRule ir2 = tc2.getRule(solver);
        OrderTranslator t = new VarToAttribTranslator(ir2);
        t = new OrderTranslator.Compose(t, new FilterTranslator(allAttribs));
        addToInstances(data, tc2, t);
    }
    data.setClassIndex(data.numAttributes() - 1);
    return data;
}
 
开发者ID:petablox-project,项目名称:petablox,代码行数:20,代码来源:TrialDataRepository.java

示例6: createInstances

import weka.core.FastVector; //导入方法依赖的package包/类
IdentifiedInstances<Element> createInstances() throws IOException {
	if (!isBagsInitialized())
		initializeBags();
	FastVector attrVector = new FastVector(attributes.size());
	for (AttributeDefinition ad : attributes)
		attrVector.addElement(ad.getAttribute());
	IdentifiedInstances<Element> result = new IdentifiedInstances<Element>(name, attrVector, 0);
	result.setClassIndex(classAttributeIndex);
	return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:11,代码来源:RelationDefinition.java

示例7: mapStringToModel

import weka.core.FastVector; //导入方法依赖的package包/类
@Override
public Dataset mapStringToModel(JsonRequest request) throws ParseException {
  
  if(request != null && request.getData() != null && request.getData().length > 0)
  {
    FastVector fvWekaAttributes = new FastVector(2);
    FastVector nil = null;
    Attribute attr0 = new Attribute("text",nil, 0);
    FastVector fv = new FastVector();
    for(String nominal : request.getClassVars())
    {
      fv.addElement(nominal);
    }
    Attribute attr1 = new Attribute("class", fv,1);
    
    fvWekaAttributes.addElement(attr0);
    fvWekaAttributes.addElement(attr1); 
    
    Instances ins = new Instances("attr-reln", fvWekaAttributes, request.getData().length);
    ins.setClassIndex(1);
    for(Text s : request.getData())
    {
      Instance i = new Instance(2);
      i.setValue(attr0, s.getText());
      i.setValue(attr1, s.getTclass());
      ins.add(i);
      
    }
    
    return new Dataset(ins);
  }
  return null;
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:34,代码来源:TEXTDataMapper.java

示例8: createVariableWekaDataset

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Creates the weka data set for clustering of variables (metabolites)
 *
 * @param rawData
 *            Data extracted from selected Raw data files and rows.
 * @return Weka library data set
 */
private Instances createVariableWekaDataset(double[][] rawData) {
    FastVector attributes = new FastVector();

    for (int i = 0; i < this.selectedRawDataFiles.length; i++) {
        String varName = "Var" + i;
        Attribute var = new Attribute(varName);
        attributes.addElement(var);
    }

    if (clusteringStep.getModule().getClass()
            .equals(HierarClusterer.class)) {
        Attribute name = new Attribute("name", (FastVector) null);
        attributes.addElement(name);
    }
    Instances data = new Instances("Dataset", attributes, 0);

    for (int i = 0; i < selectedRows.length; i++) {
        double[] values = new double[data.numAttributes()];
        System.arraycopy(rawData[i], 0, values, 0, rawData[0].length);

        if (clusteringStep.getModule().getClass()
                .equals(HierarClusterer.class)) {
            DecimalFormat twoDForm = new DecimalFormat("#.##");
            double MZ = Double.valueOf(
                    twoDForm.format(selectedRows[i].getAverageMZ()));
            double RT = Double.valueOf(
                    twoDForm.format(selectedRows[i].getAverageRT()));
            String rowName = "MZ->" + MZ + "/RT->" + RT;
            values[data.numAttributes() - 1] = data.attribute("name")
                    .addStringValue(rowName);
        }
        Instance inst = new SparseInstance(1.0, values);
        data.add(inst);
    }
    return data;
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:44,代码来源:ClusteringTask.java

示例9: determineOutputFormat

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Determines the output format based on the input format and returns 
 * this. In case the output format cannot be returned immediately, i.e.,
 * immediateOutputFormat() returns false, then this method will be called
 * from batchFinished().
 *
 * @param inputFormat     the input format to base the output format on
 * @return                the output format
 * @throws Exception      in case the determination goes wrong
 * @see   #hasImmediateOutputFormat()
 * @see   #batchFinished()
 */
protected Instances determineOutputFormat(Instances inputFormat) 
  throws Exception {

  // generate header
  FastVector atts = new FastVector();
  String prefix = getAlgorithm().getSelectedTag().getReadable();
  for (int i = 0; i < getNumComponents(); i++)
    atts.addElement(new Attribute(prefix + "_" + (i+1)));
  atts.addElement(new Attribute("Class"));
  Instances result = new Instances(prefix, atts, 0);
  result.setClassIndex(result.numAttributes() - 1);
  
  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:27,代码来源:PLSFilter.java

示例10: canHandleNClasses

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Checks whether nominal schemes can handle more than two classes.
 * If a scheme is only designed for two-class problems it should
 * throw an appropriate exception for multi-class problems.
 *
 * @param nominalPredictor if true use nominal predictor attributes
 * @param numericPredictor if true use numeric predictor attributes
 * @param stringPredictor if true use string predictor attributes
 * @param datePredictor if true use date predictor attributes
 * @param relationalPredictor if true use relational predictor attributes
 * @param multiInstance whether multi-instance is needed
 * @param numClasses the number of classes to test
 * @return index 0 is true if the test was passed, index 1 is true if test 
 *         was acceptable
 */
protected boolean[] canHandleNClasses(
    boolean nominalPredictor,
    boolean numericPredictor, 
    boolean stringPredictor, 
    boolean datePredictor,
    boolean relationalPredictor,
    boolean multiInstance,
    int numClasses) {
  
  print("more than two class problems");
  printAttributeSummary(
      nominalPredictor, numericPredictor, stringPredictor, datePredictor, relationalPredictor, multiInstance, Attribute.NOMINAL);
  print("...");
  FastVector accepts = new FastVector();
  accepts.addElement("number");
  accepts.addElement("class");
  int numTrain = getNumInstances(), missingLevel = 0;
  boolean predictorMissing = false, classMissing = false;
  
  return runBasicTest(nominalPredictor, numericPredictor, stringPredictor, 
                      datePredictor, relationalPredictor, 
                      multiInstance,
                      Attribute.NOMINAL,
                      missingLevel, predictorMissing, classMissing,
                      numTrain, numClasses, 
                      accepts);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:43,代码来源:CheckAttributeSelection.java

示例11: modifyHeader

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * modifies the header of the Instances and returns the format w/o 
 * any instances
 * 
 * @param instanceInfo the instances structure to modify
 * @return the new structure (w/o instances!)
 */
protected Instances modifyHeader(Instances instanceInfo) {
   instanceInfo = new Instances(getInputFormat(), 0); // copy before modifying
   Attribute oldAtt = instanceInfo.attribute(m_AttIndex.getIndex());
   int [] selection = new int[m_Values.size()];
   Iterator iter = m_Values.iterator();
   int i = 0;
   while (iter.hasNext()) {
      selection[i] = oldAtt.indexOfValue(iter.next().toString());
      i++;
   }
   FastVector newVals = new FastVector();
   for (i = 0; i < selection.length; i++) {
      newVals.addElement(oldAtt.value(selection[i]));
   }
   instanceInfo.deleteAttributeAt(m_AttIndex.getIndex());
   Attribute newAtt = new Attribute(oldAtt.name(), newVals);
   newAtt.setWeight(oldAtt.weight());
   instanceInfo.insertAttributeAt(newAtt,
         m_AttIndex.getIndex());
   m_NominalMapping = new int [oldAtt.numValues()];
   for (i = 0; i < m_NominalMapping.length; i++) {
      boolean found = false;
      for (int j = 0; j < selection.length; j++) {
         if (selection[j] == i) {
            m_NominalMapping[i] = j;
            found = true;
            break;
         }
      }
      if (!found) {
         m_NominalMapping[i] = -1;
      }
   }
   
   return instanceInfo;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:44,代码来源:RemoveFrequentValues.java

示例12: 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;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:22,代码来源:LabeledItemSet.java

示例13: selectElements

import weka.core.FastVector; //导入方法依赖的package包/类
FastVector selectElements(Node item, String sElement) throws Exception {
 NodeList children = item.getChildNodes();
 FastVector nodelist = new FastVector();
 for (int iNode = 0; iNode < children.getLength(); iNode++) {
Node node = children.item(iNode);
if ((node.getNodeType() == Node.ELEMENT_NODE) && node.getNodeName().equals(sElement)) {
	nodelist.addElement(node);
}
 }
 return nodelist;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:12,代码来源:BIFReader.java

示例14: canHandleZeroTraining

import weka.core.FastVector; //导入方法依赖的package包/类
/**
 * Checks whether the scheme can handle zero training instances.
 *
 * @param nominalPredictor if true use nominal predictor attributes
 * @param numericPredictor if true use numeric predictor attributes
 * @param stringPredictor if true use string predictor attributes
 * @param datePredictor if true use date predictor attributes
 * @param relationalPredictor if true use relational predictor attributes
 * @param multiInstance whether multi-instance is needed
 * @param classType the class type (NUMERIC, NOMINAL, etc.)
 * @return index 0 is true if the test was passed, index 1 is true if test 
 *         was acceptable
 */
protected boolean[] canHandleZeroTraining(
    boolean nominalPredictor,
    boolean numericPredictor, 
    boolean stringPredictor, 
    boolean datePredictor,
    boolean relationalPredictor,
    boolean multiInstance,
    int classType) {
  
  print("handle zero training instances");
  printAttributeSummary(
      nominalPredictor, numericPredictor, stringPredictor, datePredictor, relationalPredictor, multiInstance, classType);
  print("...");
  FastVector accepts = new FastVector();
  accepts.addElement("train");
  accepts.addElement("value");
  int numTrain = 0, numClasses = 2, missingLevel = 0;
  boolean predictorMissing = false, classMissing = false;
  
  return runBasicTest(
            nominalPredictor, numericPredictor, stringPredictor, 
            datePredictor, relationalPredictor, 
            multiInstance,
            classType, 
            missingLevel, predictorMissing, classMissing,
            numTrain, numClasses, 
            accepts);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:42,代码来源:CheckAssociator.java

示例15: fastVector

import weka.core.FastVector; //导入方法依赖的package包/类
private static final FastVector fastVector(Collection<String> values) {
	FastVector result = new FastVector(values.size());
	for (String v : values)
		result.addElement(v);
	return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:7,代码来源:AttributeDefinition.java


注:本文中的weka.core.FastVector.addElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。