@Override
	public double test() throws IOException {
		BufferedReader fin = new BufferedReader(new FileReader(testFile));
		String line;
		//TODO
		threshold = 1.07;
		int match = 0;
		int total = 0;
		int lineNumber = -1;
		int tp = 0;
		int tn = 0;
		int fp = 0;
		int fn = 0;
		int failCount = 0;
		while ((line = fin.readLine()) != null) {
			lineNumber++;
			if (testLineBegin != -1) {
				if (lineNumber < testLineBegin) {
					continue;
				} else if (lineNumber >= testLineEnd) {
					break;
				}
			}
			
			StringTokenizer lineTokenizer = new StringTokenizer(line);
			String account = lineTokenizer.nextToken();
			String subreddit = lineTokenizer.nextToken();
			Double affinity = Double.parseDouble(lineTokenizer.nextToken());
			
			if (!subredditIDs.containsKey(subreddit) || !accountIDs.containsKey(account)) {
				failCount++;
				continue;
			}
			double distance = euclideanDistance(U.getRow(subredditIDs.get(subreddit)), V.getRow(accountIDs.get(account)));
			
//			System.out.println(line + "\tdist = " + distance);
			// TODO affinity check
			if (distance < threshold) {
				if (affinity > 0.5) {
					match++;
					tp++;
				} else {
					fp++;
				}
			} else {
				if (affinity <= 0.5) {
					match++;
					tn++;
				} else {
					fn++;
				}
			}
			total++;
		}
	
		// Classifying the pairs that have not been trained as negative
		tn += failCount;
		match += failCount;
		
		double accuracy = (double)match / (double)total;
		double precision = (double)tp / (double)(tp + fp);
		double recall = (double)tp / (double)(tp + fn);
		System.out.println("Accuracy = " + accuracy + "\nPrecision = " + precision + "\nRecall = " + recall);
		System.out.println("Confusion matrix:\ntp = " + tp + " tn = " + tn + " fp = " + fp + " fn = " + fn);
		// System.out.println("failCount = " + failCount);
		return accuracy;
	}