Package weka.clusterers

Examples of weka.clusterers.ClusterEvaluation


              boolean numericClass = false
        final String oldText = m_visual.getText();
        try {
    if (ce.getSetNumber() == 1 ||
        ce.getClusterer() != m_clusterer) {
      m_eval = new ClusterEvaluation();
      m_clusterer = ce.getClusterer();
                  m_eval.setClusterer(m_clusterer);
    }
   
    if (ce.getSetNumber() <= ce.getMaxSetNumber()) {
View Full Code Here


              boolean numericClass = false
//        final String oldText = m_visual.getText();
        try {
    if (ce.getSetNumber() == 1 /*||
        ce.getClusterer() != m_clusterer */) {
      m_eval = new ClusterEvaluation();
      m_clusterer = ce.getClusterer();
                  m_eval.setClusterer(m_clusterer);
    }
   
    if (ce.getSetNumber() <= ce.getMaxSetNumber()) {
View Full Code Here

    }
    train.setClassIndex(-1);
    test.setClassIndex(-1);
     

    ClusterEvaluation eval = new ClusterEvaluation();

    Object [] result = new Object[overall_length];
    long trainTimeStart = System.currentTimeMillis();
    m_clusterer.buildClusterer(train);
    double numClusters = m_clusterer.numberOfClusters();
    eval.setClusterer(m_clusterer);
    long trainTimeElapsed = System.currentTimeMillis() - trainTimeStart;
    long testTimeStart = System.currentTimeMillis();
    eval.evaluateClusterer(test);
    long testTimeElapsed = System.currentTimeMillis() - testTimeStart;
    //    m_result = eval.toSummaryString();

    // The results stored are all per instance -- can be multiplied by the
    // number of instances to get absolute numbers
    int current = 0;
    result[current++] = new Double(train.numInstances());
    result[current++] = new Double(test.numInstances());

    result[current++] = new Double(eval.getLogLikelihood());
    result[current++] = new Double(numClusters);
   
    // Timing stats
    result[current++] = new Double(trainTimeElapsed / 1000.0);
    result[current++] = new Double(testTimeElapsed / 1000.0);
View Full Code Here

      }
      // copy full model for output
      SerializedObject so = new SerializedObject(clusterer);
      fullClusterer = (Clusterer) so.getObject();
     
      ClusterEvaluation eval = new ClusterEvaluation();
      eval.setClusterer(clusterer);
      switch (testMode) {
        case 3: case 5: // Test on training
        m_Log.statusMessage("Clustering training data...");
        eval.evaluateClusterer(trainInst, "", false);
        plotInstances.setInstances(inst);
        plotInstances.setClusterEvaluation(eval);
        outBuff.append("=== Model and evaluation on training set ===\n\n");
        break;

        case 2: // Percent split
        m_Log.statusMessage("Randomizing instances...");
        inst.randomize(new Random(1));
        trainInst.randomize(new Random(1));
        int trainSize = trainInst.numInstances() * percent / 100;
        int testSize = trainInst.numInstances() - trainSize;
        Instances train = new Instances(trainInst, 0, trainSize);
        Instances test = new Instances(trainInst, trainSize, testSize);
        Instances testVis = new Instances(inst, trainSize, testSize);
        m_Log.statusMessage("Building model on training split...");
        trainTimeStart = System.currentTimeMillis();
        clusterer.buildClusterer(train);
        trainTimeElapsed = System.currentTimeMillis() - trainTimeStart;
        m_Log.statusMessage("Evaluating on test split...");
        eval.evaluateClusterer(test, "", false);
        plotInstances.setInstances(testVis);
        plotInstances.setClusterEvaluation(eval);
        outBuff.append("=== Model and evaluation on test split ===\n");
        outBuff.append(clusterer.toString() + "\n");
        outBuff.append("\nTime taken to build model (percentage split) : "
                  + Utils.doubleToString(trainTimeElapsed / 1000.0,2)
                  + " seconds\n\n");
        break;
   
        case 4: // Test on user split
        m_Log.statusMessage("Evaluating on test data...");
        Instances userTestT = new Instances(userTest);
        if (!m_ignoreKeyList.isSelectionEmpty()) {
    userTestT = removeIgnoreCols(userTestT);
        }
        eval.evaluateClusterer(userTestT, "", false);
        plotInstances.setInstances(userTest);
        plotInstances.setClusterEvaluation(eval);
        outBuff.append("=== Evaluation on test set ===\n");
        break;

        default:
        throw new Exception("Test mode not implemented");
      }
      outBuff.append(eval.clusterResultsToString());
      outBuff.append("\n");
      m_History.updateResult(name);
      m_Log.logMessage("Finished " + cname);
      m_Log.statusMessage("OK");
    } catch (Exception ex) {
View Full Code Here

              m_Log.logMessage("Started reevaluate model");
              if (m_Log instanceof TaskLogger) {
                ((TaskLogger)m_Log).taskStarted();
              }
              ClusterEvaluation eval = new ClusterEvaluation();
              eval.setClusterer(clusterer);
   
              Instances userTestT = new Instances(userTest);
              if (ignoredAtts != null) {
                userTestT = removeIgnoreCols(userTestT, ignoredAtts);
              }

              eval.evaluateClusterer(userTestT);
     
              plotInstances.setClusterEvaluation(eval);
              plotInstances.setInstances(userTest);
              plotInstances.setUp();

              outBuff.append("\n=== Re-evaluation on test set ===\n\n");
              outBuff.append("User supplied test set\n")
              outBuff.append("Relation:     " + userTest.relationName() + '\n');
              outBuff.append("Instances:    " + userTest.numInstances() + '\n');
              outBuff.append("Attributes:   " + userTest.numAttributes() + "\n\n");
              if (trainHeader == null)
                outBuff.append("NOTE - if test set is not compatible then results are "
                               + "unpredictable\n\n");
     
              outBuff.append(eval.clusterResultsToString());
              outBuff.append("\n");
              m_History.updateResult(name);
              m_Log.logMessage("Finished re-evaluation");
              m_Log.statusMessage("OK");
            } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of weka.clusterers.ClusterEvaluation

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.