Package weka.classifiers

Examples of weka.classifiers.Classifier


  public static void runClassifierCV(WekaClassifier wekaClassifier, Dataset dataset)
    throws Exception
  {
    // Set parameters
    int folds = 10;
    Classifier baseClassifier = ClassifierSimilarityMeasure.getClassifier(wekaClassifier);
   
    // Set up the random number generator
      long seed = new Date().getTime();     
    Random random = new Random(seed)
     
    // Add IDs to the instances
    AddID.main(new String[] {"-i", MODELS_DIR + "/" + dataset.toString() + ".arff",
                  "-o", MODELS_DIR + "/" + dataset.toString() + "-plusIDs.arff" });
    Instances data = DataSource.read(MODELS_DIR + "/" + dataset.toString() + "-plusIDs.arff");
    data.setClassIndex(data.numAttributes() - 1);       
   
        // Instantiate the Remove filter
        Remove removeIDFilter = new Remove();
      removeIDFilter.setAttributeIndices("first");
       
    // Randomize the data
    data.randomize(random);
 
    // Perform cross-validation
      Instances predictedData = null;
      Evaluation eval = new Evaluation(data);
     
      for (int n = 0; n < folds; n++)
      {
        Instances train = data.trainCV(folds, n, random);
          Instances test = data.testCV(folds, n);
         
          // Apply log filter
//        Filter logFilter = new LogFilter();
//          logFilter.setInputFormat(train);
//          train = Filter.useFilter(train, logFilter);       
//          logFilter.setInputFormat(test);
//          test = Filter.useFilter(test, logFilter);
         
          // Copy the classifier
          Classifier classifier = AbstractClassifier.makeCopy(baseClassifier);
                                
          // Instantiate the FilteredClassifier
          FilteredClassifier filteredClassifier = new FilteredClassifier();
          filteredClassifier.setFilter(removeIDFilter);
          filteredClassifier.setClassifier(classifier);
View Full Code Here


  if (((Double)((FastVector)m_focus.m_ranges.elementAt(0)).
       elementAt(0)).intValue() != LEAF) {
    m_iView.setShapes(m_focus.m_ranges);
  }
 
  Classifier classifierAtNode = m_focus.getClassifier();
        if (classifierAtNode != null) {
          m_classifiers.setValue(classifierAtNode);
        }
  m_propertyDialog = new PropertyDialog(m_classifiers,
                m_mainWin.getLocationOnScreen().x,
View Full Code Here

  argsR = new String [args.length-10];
  for (int j = 10; j < args.length; j++) {
    argsR[j-10] = args[j];
  }
      }
      Classifier c = Classifier.forName(args[9], argsR);
      KDDataGenerator dataGen = new KDDataGenerator();
      dataGen.setKernelBandwidth(bandWidth);
      bv.setDataGenerator(dataGen);
      bv.setNumSamplesPerRegion(loc);
      bv.setGeneratorSamplesBase(base);
View Full Code Here

  argsR = new String [args.length-10];
  for (int j = 10; j < args.length; j++) {
    argsR[j-10] = args[j];
  }
      }
      Classifier c = Classifier.forName(args[9], argsR);
      KDDataGenerator dataGen = new KDDataGenerator();
      dataGen.setKernelBandwidth(bandWidth);
      bv.setDataGenerator(dataGen);
      bv.setNumSamplesPerRegion(loc);
      bv.setGeneratorSamplesBase(base);
View Full Code Here

    FastVector attributes = new FastVector();
    Instances metaFormat;

    for (int k = 0; k < m_Classifiers.length; k++) {
      Classifier classifier = (Classifier) getClassifier(k);
      String name = classifier.getClass().getName();
      if (m_BaseFormat.classAttribute().isNumeric()) {
  attributes.addElement(new Attribute(name));
      } else {
  for (int j = 0; j < m_BaseFormat.classAttribute().numValues(); j++) {
    attributes.addElement(new Attribute(name + ":" +
View Full Code Here

    double[] values = new double[m_MetaFormat.numAttributes()];
    Instance metaInstance;
    int i = 0;
    for (int k = 0; k < m_Classifiers.length; k++) {
      Classifier classifier = getClassifier(k);
      if (m_BaseFormat.classAttribute().isNumeric()) {
  values[i++] = classifier.classifyInstance(instance);
      } else {
  double[] dist = classifier.distributionForInstance(instance);
  for (int j = 0; j < dist.length; j++) {
    values[i++] = dist[j];
  }
      }
    }
View Full Code Here

    Vector<Performance>    performances;
    PointDouble      values;
    Instances      data;
    Evaluation      eval;
    PointDouble      result;
    Classifier      classifier;
    Filter      filter;
    int        size;
    boolean      cached;
    boolean      allCached;
    Performance      p1;
View Full Code Here

    repaint();
  }
      });
    ((GenericObjectEditor.GOEPanel) m_ClassifierEditor.getCustomEditor()).addOkListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    Classifier newCopy =
      (Classifier) copyObject(m_ClassifierEditor.getValue());
    addNewAlgorithm(newCopy);
  }
      });
   
View Full Code Here

          try {
            File file = m_FileChooser.getSelectedFile();
            if (!file.getAbsolutePath().toLowerCase().endsWith(".xml"))
              file = new File(file.getAbsolutePath() + ".xml");
            XMLClassifier xmlcls = new XMLClassifier();
            Classifier c = (Classifier) xmlcls.read(file);
            m_AlgorithmListModel.setElementAt(c, m_List.getSelectedIndex());
            updateExperiment();
          }
          catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

      m_Exp.setRunLower(1);
      m_Exp.setRunUpper(m_numRepetitions);
    }

    SplitEvaluator se = null;
    Classifier sec = null;
    if (m_ExpClassificationRBut.isSelected()) {
      se = new ClassifierSplitEvaluator();
      sec = ((ClassifierSplitEvaluator)se).getClassifier();
    } else {
      se = new RegressionSplitEvaluator();
View Full Code Here

TOP

Related Classes of weka.classifiers.Classifier

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.