Package weka.core

Examples of weka.core.FastVector


    FastVector[] rules;

    // Build rules
    for (int j = 1; j < m_Ls.size(); j++) {
      FastVector currentItemSets = (FastVector)m_Ls.elementAt(j);
      Enumeration enumItemSets = currentItemSets.elements();
      while (enumItemSets.hasMoreElements()) {
  AprioriItemSet currentItemSet = (AprioriItemSet)enumItemSets.nextElement();
        //AprioriItemSet currentItemSet = new AprioriItemSet((ItemSet)enumItemSets.nextElement());
  rules=currentItemSet.generateRulesBruteForce(m_minMetric,m_metricType,
          m_hashtables,j+1,
View Full Code Here


  private void findRulesQuickly() throws Exception {

    FastVector[] rules;
    // Build rules
    for (int j = 1; j < m_Ls.size(); j++) {
      FastVector currentItemSets = (FastVector)m_Ls.elementAt(j);
      Enumeration enumItemSets = currentItemSets.elements();
      while (enumItemSets.hasMoreElements()) {
  AprioriItemSet currentItemSet = (AprioriItemSet)enumItemSets.nextElement();
        //AprioriItemSet currentItemSet = new AprioriItemSet((ItemSet)enumItemSets.nextElement());
  rules = currentItemSet.generateRules(m_minMetric, m_hashtables, j + 1);
  for (int k = 0; k < rules[0].size(); k++) {
View Full Code Here

     * Method that finds all large itemsets for class association rules for the given set of instances.
     * @throws Exception if an attribute is numeric
     */
    private void findLargeCarItemSets() throws Exception {
 
  FastVector kMinusOneSets, kSets;
  Hashtable hashtable;
  int necSupport, necMaxSupport,i = 0;
 
  // Find large itemsets
 
  // minimum support
        double nextMinSupport = m_minSupport*(double)m_instances.numInstances();
        double nextMaxSupport = m_upperBoundMinSupport*(double)m_instances.numInstances();
  if((double)Math.rint(nextMinSupport) == nextMinSupport){
            necSupport = (int) nextMinSupport;
        }
        else{
            necSupport = Math.round((float)(nextMinSupport+0.5));
        }
        if((double)Math.rint(nextMaxSupport) == nextMaxSupport){
            necMaxSupport = (int) nextMaxSupport;
        }
        else{
            necMaxSupport = Math.round((float)(nextMaxSupport+0.5));
        }
 
  //find item sets of length one
  kSets = LabeledItemSet.singletons(m_instances,m_onlyClass);
  LabeledItemSet.upDateCounters(kSets, m_instances,m_onlyClass);
       
        //check if a item set of lentgh one is frequent, if not delete it
  kSets = LabeledItemSet.deleteItemSets(kSets, necSupport, m_instances.numInstances());
        if (kSets.size() == 0)
      return;
  do {
      m_Ls.addElement(kSets);
      kMinusOneSets = kSets;
      kSets = LabeledItemSet.mergeAllItemSets(kMinusOneSets, i, m_instances.numInstances());
      hashtable = LabeledItemSet.getHashtable(kMinusOneSets, kMinusOneSets.size());
      kSets = LabeledItemSet.pruneItemSets(kSets, hashtable);
      LabeledItemSet.upDateCounters(kSets, m_instances,m_onlyClass);
      kSets = LabeledItemSet.deleteItemSets(kSets, necSupport, m_instances.numInstances());
      i++;
  } while (kSets.size() > 0);
View Full Code Here

    FastVector[] rules;

    // Build rules
    for (int j = 0; j < m_Ls.size(); j++) {
      FastVector currentLabeledItemSets = (FastVector)m_Ls.elementAt(j);
      Enumeration enumLabeledItemSets = currentLabeledItemSets.elements();
      while (enumLabeledItemSets.hasMoreElements()) {
  LabeledItemSet currentLabeledItemSet = (LabeledItemSet)enumLabeledItemSets.nextElement();
  rules = currentLabeledItemSet.generateRules(m_minMetric,false);
  for (int k = 0; k < rules[0].size(); k++) {
    m_allTheRules[0].addElement(rules[0].elementAt(k));
View Full Code Here

        } catch (Exception ex) {
    System.err.println(ex);
        }
        plotInstances.cleanUp();

        FastVector vv = new FastVector();
        vv.addElement(fullClusterer);
        Instances trainHeader = new Instances(m_Instances, 0);
        vv.addElement(trainHeader);
        if (ignoredAtts != null) vv.addElement(ignoredAtts);
        if (saveVis) {
    vv.addElement(m_CurrentVis);
    if (grph != null) {
      vv.addElement(grph);
    }
   
        }
        m_History.addObject(name, vv);
      }
View Full Code Here

    loadClusterer();
  }
      });
    resultListMenu.add(loadModel);

    FastVector o = null;
    if (selectedName != null) {
      o = (FastVector)m_History.getNamedObject(selectedName);
    }

    VisualizePanel temp_vp = null;
    String temp_grph = null;
    Clusterer temp_clusterer = null;
    Instances temp_trainHeader = null;
    int[] temp_ignoreAtts = null;
   
    if (o != null) {
      for (int i = 0; i < o.size(); i++) {
  Object temp = o.elementAt(i);
  if (temp instanceof Clusterer) {
    temp_clusterer = (Clusterer)temp;
  } else if (temp instanceof Instances) { // training header
    temp_trainHeader = (Instances)temp;
  } else if (temp instanceof int[]) { // ignored attributes
View Full Code Here

  outBuff.append("\n=== Clustering model ===\n\n");
  outBuff.append(clusterer.toString() + "\n");

  m_History.addResult(name, outBuff);
  m_History.setSingle(name);
  FastVector vv = new FastVector();
  vv.addElement(clusterer);
  if (trainHeader != null) vv.addElement(trainHeader);
  if (ignoredAtts != null) vv.addElement(ignoredAtts);
  // allow visualization of graphable classifiers
  String grph = null;
  if (clusterer instanceof Drawable) {
    try {
      grph = ((Drawable)clusterer).graph();
    } catch (Exception ex) {
    }
  }
  if (grph != null) vv.addElement(grph);
 
  m_History.addObject(name, vv);
 
      }
    }
View Full Code Here

                  m_CurrentVis.addPlot(plotInstances.getPlotData(name));
                } catch (Exception ex) {
                  System.err.println(ex);
                }
 
                FastVector vv = new FastVector();
                vv.addElement(clusterer);
                if (trainHeader != null) vv.addElement(trainHeader);
                if (ignoredAtts != null) vv.addElement(ignoredAtts);
                if (saveVis) {
                  vv.addElement(m_CurrentVis);
                  if (grph != null) {
                    vv.addElement(grph);
                  }
   
                }
                m_History.addObject(name, vv);
View Full Code Here

    m_Values.setUpper(instanceInfo.attribute(m_AttIndex.getIndex()).numValues() - 1);
    if (isNominal() && m_ModifyHeader) {
      instanceInfo = new Instances(instanceInfo, 0); // copy before modifying
      Attribute oldAtt = instanceInfo.attribute(m_AttIndex.getIndex());
      int [] selection = m_Values.getSelection();
      FastVector newVals = new FastVector();
      for (int i = 0; i < selection.length; i++) {
  newVals.addElement(oldAtt.value(selection[i]));
      }
      instanceInfo.deleteAttributeAt(m_AttIndex.getIndex());
      instanceInfo.insertAttributeAt(new Attribute(oldAtt.name(), newVals),
              m_AttIndex.getIndex());
      m_NominalMapping = new int [oldAtt.numValues()];
View Full Code Here

        new weka.classifiers.evaluation.ThresholdCurve();
      weka.classifiers.evaluation.EvaluationUtils eu =
        new weka.classifiers.evaluation.EvaluationUtils();
      //weka.classifiers.Classifier classifier = new weka.classifiers.functions.Logistic();
      weka.classifiers.Classifier classifier = new weka.classifiers.bayes.NaiveBayes();
      FastVector predictions = new FastVector();
      eu.setSeed(1);
      predictions.appendElements(eu.getCVPredictions(classifier, train, 10));
      Instances result = tc.getCurve(predictions, 0);
      PlotData2D pd = new PlotData2D(result);
      pd.m_alwaysDisplayPointsOfThisSize = 10;

      boolean[] connectPoints = new boolean[result.numInstances()];
View Full Code Here

TOP

Related Classes of weka.core.FastVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.