Package weka.classifiers

Examples of weka.classifiers.Classifier


        int classIndex = TupleUtilities.getColumnIndex(iterationInputs[1], metadata, INPUT_CLASS_INDEX);
        Map<Integer, List<Object>> nominalValues =
            getNominalValues(iterationInputs, metadata);
        Instances dataset = WekaUtilities.createClassificationDataset(tuples, classIndex, nominalValues);
        String options = TupleUtilities.getAsString(iterationInputs[2], INPUT_OPTIONS);
        Classifier classifier = null;
        try
        {
          classifier = loadClassifier(options);
        }
        catch(InvalidWekaOptionsException exc)
        {
          throw new ActivityUserException(exc);
        }

        try
        {
            classifier.buildClassifier(dataset);
        }
        catch (Exception e)
        {
            throw new ActivityUserException(e);
        }
View Full Code Here


        {
          if(options == null || options == "")
          options = DEFAULT_OPTIONS;
            Class<? extends Classifier> classifierClass =
                Class.forName(mClassifierName).asSubclass(Classifier.class);
            Classifier classifier = classifierClass.newInstance();
        String[] opt = weka.core.Utils.splitOptions(options);
        ((OptionHandler)classifier).setOptions(opt);         
            return classifier;
        }
        catch (Exception e)
View Full Code Here

   *
   * @return     the classifier string.
   */
  protected String getClassifierSpec() {
    String  result;
    Classifier   c;

    c      = getClassifier();
    result = c.getClass().getName();
    if (c instanceof OptionHandler)
      result += " " + Utils.joinOptions(((OptionHandler) c).getOptions());

    return result;
  }
View Full Code Here

    add(m_ClassifierEditor, BorderLayout.CENTER);
    add(holder2, BorderLayout.SOUTH);
  }
 
  private void checkOnClassifierType() {
    Classifier editedC = m_dsClassifier.getClassifierTemplate();
    if (editedC instanceof weka.classifiers.UpdateableClassifier &&
  m_dsClassifier.hasIncomingStreamInstances()) {
      if (!m_panelVisible) {
  m_holderPanel.add(m_incrementalPanel, BorderLayout.SOUTH);
  m_panelVisible = true;
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() + "-" + (k+1);
      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

    delTransform.setAttributeIndicesArray(featArray);
    delTransform.setInputFormat(trainCopy);
    trainCopy = Filter.useFilter(trainCopy, delTransform);
    o_Evaluation = new Evaluation(trainCopy);
    String [] oneROpts = { "-B", ""+getMinimumBucketSize()};
    Classifier oneR = Classifier.forName("weka.classifiers.rules.OneR", oneROpts);
    if (m_evalUsingTrainingData) {
      oneR.buildClassifier(trainCopy);
      o_Evaluation.evaluateModel(oneR, trainCopy);
    } else {
      /*      o_Evaluation.crossValidateModel("weka.classifiers.rules.OneR",
              trainCopy, 10,
              null, new Random(m_randomSeed)); */
 
View Full Code Here

    //newWindowButton.setPreferredSize(new Dimension(120, m_addRemovePointsPanel.getHeight()));
    newWindowButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
    try {
      Instances newTrainingData = null;
      Classifier newClassifier = null;
      if (m_trainingInstances != null)
        newTrainingData = new Instances(m_trainingInstances);
      if (m_classifier != null)
        newClassifier = Classifier.makeCopy(m_classifier);
      createNewVisualizerWindow(newClassifier, newTrainingData);
View Full Code Here

      argsR = new String [args.length-2];
      for (int j = 2; j < args.length; j++) {
      argsR[j-2] = args[j];
      }
    }
    Classifier c = Classifier.forName(args[1], argsR);
   
    System.err.println(Messages.getInstance().getString("BoundaryVisualizer_Main_Error_Text") + args[0]);
    java.io.Reader r = new java.io.BufferedReader(
          new java.io.FileReader(args[0]));
    Instances i = new Instances(r);
View Full Code Here

   * @param data  the data to use (J48 with nominal class, M5P with
   *       numeric class)
   * @return    the results for the data
   */
  protected double[] trainAndSerializeClassifier(Instances data) {
    Classifier  classifier;
    double[]  result;
    int    i;
   
    try {
      // build
      if (data.classAttribute().isNominal())
  classifier = new weka.classifiers.trees.J48();
      else
  classifier = new weka.classifiers.trees.M5P();
      classifier.buildClassifier(data);
     
      // record predictions
      result = new double[data.numInstances()];
      for (i = 0; i < result.length; i++)
  result[i] = classifier.classifyInstance(data.instance(i));
     
      // save
      SerializationHelper.write(MODEL_FILENAME, classifier);
    }
    catch (Exception e) {
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.