All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cc.mallet.classify.evaluate.AccuracyCoverage Maven / Gradle / Ivy

Go to download

MALLET is a Java-based package for statistical natural language processing, document classification, clustering, topic modeling, information extraction, and other machine learning applications to text.

The newest version!
/* Copyright (C) 2002 Univ. of Massachusetts Amherst, Computer Science Dept.
   This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).
   http://www.cs.umass.edu/~mccallum/mallet
   This software is provided under the terms of the Common Public License,
   version 1.0, as published by http://www.opensource.org.  For further
   information, see the file `LICENSE' included with this distribution. */


/** 
   @author Aron Culotta [email protected]
 */

package cc.mallet.classify.evaluate;


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import cc.mallet.classify.Classification;
import cc.mallet.classify.Classifier;
import cc.mallet.classify.Trial;
import cc.mallet.classify.evaluate.GraphItem;
import cc.mallet.types.InstanceList;
import cc.mallet.types.LabelVector;
import cc.mallet.util.MalletLogger;
import cc.mallet.util.PrintUtilities;

import java.util.*;
import java.util.logging.*;
import java.text.DecimalFormat;

/**
 * Methods for calculating and displaying the accuracy v.
 * coverage data for a Trial
 */
public class AccuracyCoverage implements ActionListener
{
	private static Logger logger = MalletLogger.getLogger(AccuracyCoverage.class.getName());
	static final int DEFAULT_NUM_BUCKETS = 20;
	static final int DEFAULT_MAX_X = 100;
	private ArrayList classifications;
	private double [] accuracyValues;
	private int numBuckets;
	private double step;
	private Graph2 graph;
	private JFrame frame;
	
	/**
	 * Constructs object, sorts classifications, and creates
	 * accuracyValues array
     * @param t trial to get data from
     * @param numBuckets number of x-axis measurements to find accuracy
     */
	public AccuracyCoverage(Trial t, int numBuckets, String title, String dataName)
	{
		this.classifications = t;
		this.numBuckets = numBuckets;
		this.step = (double)DEFAULT_MAX_X/numBuckets;
		this.accuracyValues = new double[numBuckets];
		this.frame = null;
		logger.info("Constructing AccCov with " + 
											 this.classifications.size()); 
		sortClassifications();
/*		for(int i=0; i 0)
				toReturn = 1;
			else if (difference < 0)
				toReturn = -1;
			return(toReturn);		
		}
		
	}
	
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy