public void test(DistanceMetricMethod method, List<Instance> testInstances, File sysOutputFile, String dataType) throws IOException {
		Map<String, Frequency<String>> confusionMatrix = new HashMap<String, Frequency<String>>();
		
		SysOutput output = new SysOutput(sysOutputFile);
		output.printHeader(dataType);
		
		for (Instance testInstance : testInstances) {
			Map<Instance,Double> distances = new HashMap<Instance,Double>();
			Set<String> classes = new HashSet<String>();
			
			for (Instance trainInstance : this.trainInstances) {
				double distance = this.getDistance(method, trainInstance, testInstance);
							
				distances.put(trainInstance, distance);
				classes.add(trainInstance.getLabel());
			}
			
			Map<Instance,Double> neighbors = this.getNearest(method, distances);
			
			Frequency<String> classCounts = new Frequency<String>();
			
			for (Map.Entry<Instance,Double> neighbor : neighbors.entrySet()) {
				classCounts.count(neighbor.getKey().getLabel());
			}
			
			Map<String,Double> classProbabilities = new HashMap<String,Double>();
			
			for (String classLabel : classes) {
				classProbabilities.put(classLabel, 0d);
			}
			
			double highProb = 0;
			String highProbLabel = "";
			
			for (Map.Entry<String,Integer> count : classCounts.getCounts().entrySet()) {
				String classLabel = count.getKey();
				int classCount = count.getValue();
				
				double probability = (double)classCount/(double)this.kVal;
				classProbabilities.put(classLabel,probability);
				
				if (probability > highProb || highProb == 0) {
					highProb = probability;
					highProbLabel = classLabel; 
				}
			}
			
			output.printClassProbabilities(testInstance.getId(), classProbabilities, testInstance.getLabel());			
			
			Frequency<String> labelCounts = confusionMatrix.get(testInstance.getLabel());
			if (labelCounts == null)
				labelCounts = new Frequency<String>();
			
			labelCounts.count(highProbLabel);
			
			confusionMatrix.put(testInstance.getLabel(), labelCounts);
		}
		
		output.close();
		
		printConfusionMatrix(confusionMatrix, dataType);
	}