Commits

muzny committed 8864553

Removing unused code.

Comments (0)

Files changed (3)

WiktionaryIdioms/src/classifier/experiments/Bootstrapping.java

-package classifier.experiments;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-
-import classifier.classifiers.Classifier;
-import classifier.config.ClassifierConfigs;
-import classifier.model.ClassifierData;
-import classifier.model.ClassifierEvaluationUtils;
-import classifier.model.ClassifierModel;
-import classifier.model.Result;
-import classifier.model.Sense;
-import classifier.utilities.ClassifierDataUtils;
-
-public class Bootstrapping implements Experiment {
-	public static final String CONFIG_STR = "Bootstrapping";
-
-	@Override
-	public ExperimentResult runExperiment(ClassifierConfigs configs, List<ClassifierData> train, List<ClassifierData> test) {
-		// TODO Auto-generated method stub
-		configs.setSection(CONFIG_STR);
-		
-		boolean verbose = configs.getSBool(ClassifierConfigs.VERBOSE);
-		int iterations = configs.getSInt("iterations");
-		double cutoffMin = configs.getSDouble("cutoffMin");
-		double cutoffMax = configs.getSDouble("cutoffMax");
-		double cutoffIncrement = configs.getSDouble("cutoffIncrement");
-		
-		System.out.println("verbose: " + verbose);
-		String modelFile = configs.getSString("modelFile");
-		
-		
-		// get original labels
-		Map<String, Integer> originals = new HashMap<String, Integer>();
-		for (ClassifierData cd : train) {
-			originals.put(cd.getKey(), cd.getLabel());
-		}
-		for (ClassifierData cd : test) {
-			originals.put(cd.getKey(), cd.getLabel());
-		}
-		
-		List<ExperimentResult> results = new ArrayList<ExperimentResult>();
-		for (double i = cutoffMin; i <= cutoffMax; i += cutoffIncrement) {
-			System.out.println("*************************");
-			System.out.println("cutoff: " + i);
-			Classifier classy = null;
-			ClassifierModel resultModel = null;
-			if (modelFile.length() > 0) {
-				System.out.println("Loading from model file: " + modelFile);
-				resultModel = new ClassifierModel(new File(modelFile));
-				classy = configs.getClassifier(resultModel);
-			}			
-			
-			System.out.println("Base classifier:");
-			System.out.println(classy);
-			System.out.println(ClassifierDataUtils.getGeneralDataAnalysis(train));
-			System.out.println(ClassifierDataUtils.getGeneralDataAnalysis(test));
-
-			
-			List<ExperimentResult> subResults = runBootstrap(configs, classy, train, test, iterations, i);
-			results.addAll(subResults);
-			
-			// reset original labels
-			for (ClassifierData cd : train) {
-				cd.setLabel(originals.get(cd.getKey()));
-			}
-			for (ClassifierData cd : test) {
-				cd.setLabel(originals.get(cd.getKey()));
-			}			
-		}
-		
-		return results.get(0);
-	}
-	
-	private static List<ExperimentResult> runBootstrap(ClassifierConfigs configs, Classifier classy, 
-			List<ClassifierData> train, List<ClassifierData> test, 
-			int iterations, double cutoff) {
-		List<ExperimentResult> exResults = new ArrayList<ExperimentResult>();
-		
-		int count = 1;
-		TreeMap<Integer, List<ClassifierData>> results = classy.test(test);
-		double prevFMeasure = ClassifierEvaluationUtils.getFMeasure(results, 1);
-		System.out.println("F-measure: " + prevFMeasure);
-		double change = prevFMeasure;
-		
-		while (count <= iterations) {
-			// use the classifier to re-label the training
-			List<Result> trainingDeltas = classy.testGetSortedDeltas(train);
-			
-			TreeMap<Integer, List<ClassifierData>> classifications = 
-					ExperimentResult.produceClassificationsFromCutoff(trainingDeltas, cutoff);
-			
-			for (int label : classifications.keySet()) {
-				for (ClassifierData cd : classifications.get(label)) {
-					cd.setLabel(label);
-				}
-			}
-			
-			System.out.println("###########");
-			System.out.println("iteration: " + count);
-			count++;
-
-			System.out.println(ClassifierDataUtils.getGeneralDataAnalysis(train));
-			System.out.println(ClassifierDataUtils.getGeneralDataAnalysis(test));
-
-			
-			// now train a new classifier with this training data
-			Experiment subE = new CompareGroups();
-			ExperimentResult subResult = subE.runExperiment(configs, train, test);
-			exResults.add(subResult);
-
-			classy = configs.getClassifier(subResult.model);
-			results = classy.test(test);
-			double fMeasure = ClassifierEvaluationUtils.getFMeasure(results, 1);
-			
-			change = fMeasure - prevFMeasure;
-			prevFMeasure = fMeasure;
-			
-			System.out.println(subResult);
-			System.out.println("F-measure: " + fMeasure);
-			System.out.println("change: " + change);
-			System.out.println();
-		}
-		return exResults;
-	}
-
-	
-}

WiktionaryIdioms/src/classifier/experiments/RunClassifierExperimentFromFiles.java

 import java.util.List;
 
 import classifier.config.ClassifierConfigs;
-import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 import classifier.utilities.ClassifierDataUtils;
 
 			e = new CompareFeatures();
 		} else if (type.equals("comparegroups")) {
 			e = new CompareGroups();
-		} else if (type.equals("bootstrapping")) {
-			e = new Bootstrapping();
 		} else {
 			System.err.println("Invalid experiment type, please choose \"basic\", \"grid\", "
 					+ "\"compare\", \"comparegroups\", or \"bootstrapping\"");

WiktionaryIdioms/src/classifier/experiments/RunExperiment.java

 			e = new CompareFeatures();
 		} else if (type.equals("comparegroups")) {
 			e = new CompareGroups();
-		} else if (type.equals("bootstrapping")) {
-			e = new Bootstrapping();
+		} else {
+			System.err.println("Error in specifying experiment type, must be \"basic\"" +
+					", \"grid\", \"compare\", or \"comparegroups\"");
 		}
 		
 		System.out.println("Using an experiment of type: " + e);