Package weka.classifiers

Examples of weka.classifiers.Classifier


      values[idx] = instance.value(i);
      idx++;
  }
    }

    Classifier classifier = getClassifier(k);

    if (m_BaseFormat.classAttribute().isNumeric()) {
      throw new Exception("Class Attribute must not be numeric!");
    } else {
      double[] dist = classifier.distributionForInstance(instance);
     
      maxIdx=0;
      maxVal=dist[0];
      for (int j = 1; j < dist.length; j++) {
  if (dist[j]>maxVal) {
View Full Code Here


      Instances inst = new Instances(new java.io.InputStreamReader(System.in));
     
      inst.setClassIndex(inst.numAttributes() - 1);
      CostCurve cc = new CostCurve();
      EvaluationUtils eu = new EvaluationUtils();
      Classifier classifier = new weka.classifiers.functions.Logistic();
      FastVector predictions = new FastVector();
      for (int i = 0; i < 2; i++) { // Do two runs.
  eu.setSeed(i);
  predictions.appendElements(eu.getCVPredictions(classifier, inst, 10));
  //System.out.println("\n\n\n");
View Full Code Here

     
      int total = models.size();
      int invalid = 0;
     
      for (int i = 0; i < models.size(); i++) {
  Classifier classifier = (Classifier) models.get(i);
 
  //This method will invoke the classifier's setOptions
  //method to see if the current set of options was
  //valid. 
 
View Full Code Here

        System.out.println( ThresholdCurve.getNPointPrecision( inst, 11 ) );
      } else {
        inst.setClassIndex( inst.numAttributes() - 1 );
        ThresholdCurve tc = new ThresholdCurve();
        EvaluationUtils eu = new EvaluationUtils();
        Classifier classifier = new weka.classifiers.functions.Logistic();
        FastVector predictions = new FastVector();
        for( int i = 0; i < 2; i++ ) { // Do two runs.

          eu.setSeed( i );
          predictions.appendElements( eu.getCVPredictions( classifier, inst, 10 ) );
View Full Code Here

   *
   * @return the classifier string.
   */
  protected String getClassifierSpec() {
   
    Classifier c = getClassifier();
    if (c instanceof OptionHandler) {
      return c.getClass().getName() + " "
  + Utils.joinOptions(((OptionHandler)c).getOptions());
    }
    return c.getClass().getName();
  }
View Full Code Here

   *
   * @return the classifier string.
   */
  protected String getClassifierSpec() {
   
    Classifier c = getClassifier();
    return c.getClass().getName() + " "
      + Utils.joinOptions(((OptionHandler)c).getOptions());
  }
View Full Code Here

  if(artSize==0) artSize=1;//atleast add one random example
  computeStats(data);//Compute training data stats for creating artificial examples
 
  //initialize new committee
  m_Committee = new Vector();
  Classifier newClassifier = m_Classifier;
  newClassifier.buildClassifier(divData);
  m_Committee.add(newClassifier);
  double eComm = computeError(divData);//compute ensemble error
  if(m_Debug) System.out.println("Initialize:\tClassifier "+i+" added to ensemble. Ensemble error = "+eComm);
 
  //repeat till desired committee size is reached OR the max number of iterations is exceeded
  while(i<m_DesiredSize && numTrials<m_NumIterations){
      //Generate artificial training examples
      artData = generateArtificialData(artSize, data);
     
      //Label artificial examples
      labelData(artData);
      addInstances(divData, artData);//Add new artificial data
     
      //Build new classifier
      Classifier tmp[] = Classifier.makeCopies(m_Classifier,1);
      newClassifier = tmp[0];
      newClassifier.buildClassifier(divData);
      //Remove all the artificial data
      removeInstances(divData, artSize);
     
View Full Code Here

  public double[] distributionForInstance(Instance instance) throws Exception {
      if (instance.classAttribute().isNumeric()) {
    throw new UnsupportedClassTypeException("Decorate can't handle a numeric class!");
      }
      double [] sums = new double [instance.numClasses()], newProbs;
      Classifier curr;
     
      for (int i = 0; i < m_Committee.size(); i++) {
    curr = (Classifier) m_Committee.get(i);
    newProbs = curr.distributionForInstance(instance);
    for (int j = 0; j < newProbs.length; j++)
      sums[j] += newProbs[j];
      }
      if (Utils.eq(Utils.sum(sums), 0)) {
    return sums;
View Full Code Here

    setLayout(new BorderLayout());
    add(m_ClassifierEditor, BorderLayout.CENTER);
  }
 
  private void checkOnClassifierType() {
    Classifier editedC = m_dsClassifier.getClassifier();
    if (editedC instanceof weka.classifiers.UpdateableClassifier &&
  m_dsClassifier.hasIncomingStreamInstances()) {
      if (!m_panelVisible) {
  add(m_incrementalPanel, BorderLayout.SOUTH);
  m_panelVisible = true;
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

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.