public static FastKNN loadKNN(BTFData btf) throws IOException { System.out.println("[AntKNN] Loading BTF data..."); FastKNN knn = new FastKNN(FEATURE_DIM, 3); String[] desiredVel = btf.loadColumn("dvel"); String[] desiredVelBool = btf.loadColumn("dbool"); String[] wallVec = btf.loadColumn("wallvec"); String[] wallBool = btf.loadColumn("wallbool"); String[] antVec = btf.loadColumn("antvec"); String[] antBool = btf.loadColumn("antbool"); String[] homeVec = btf.loadColumn("homevec"); String[] foodVec = btf.loadColumn("foodvec"); String[] prevVec = btf.loadColumn("pvel"); String[] prevBoolVec = btf.loadColumn("pbool"); int numRows = desiredVel.length; double[] sample = new double[FEATURE_DIM]; double[] velclass = new double[3]; for (int i = 0; i < numRows; i++) { if (i % (numRows / 10) == 0) System.out.println("[AntKNN] " + i + "/" + numRows); if (Boolean.parseBoolean(desiredVelBool[i])) { String[] tmp = desiredVel[i].split(" "); velclass[0] = Double.parseDouble(tmp[0]); velclass[1] = Double.parseDouble(tmp[1]); velclass[2] = Double.parseDouble(tmp[2]); tmp = antVec[i].split(" "); sample[0] = Double.parseDouble(tmp[0]); sample[1] = Double.parseDouble(tmp[1]); tmp = wallVec[i].split(" "); sample[2] = Double.parseDouble(tmp[0]); sample[3] = Double.parseDouble(tmp[1]); tmp = homeVec[i].split(" "); sample[4] = Double.parseDouble(tmp[0]); sample[5] = Double.parseDouble(tmp[1]); // tmp = foodVec[i].split(" "); // sample[6] = Double.parseDouble(tmp[0]); // sample[7] = Double.parseDouble(tmp[1]); // tmp = prevVec[i].split(" "); // sample[4] = Double.parseDouble(tmp[0]); // sample[5] = Double.parseDouble(tmp[1]); // sample[6] = Double.parseDouble(tmp[2]); // tmp = homeVec[i].split(" "); // sample[7] = Double.parseDouble(tmp[0]); // sample[8] = Double.parseDouble(tmp[1]); knn.add(sample, velclass); } } // sigmaNormalize currently broken, don't use it! (Dec 4th, 2012) // knn.sigmaNormalize(); System.out.println("[AntKNN] Done!"); return knn; }