public static void trainModel(ActionBarActivity obj) throws IOException, ClassNotFoundException { ArrayList<Feature> features = Globals.getAllFeatures(obj); ArrayList<ArrayList<Double>> train = new ArrayList<ArrayList<Double>>(); ArrayList<Double> temp; for (Feature f : features) { temp = new ArrayList<>(); temp.add((double) f._classLabel); temp.addAll(f._features); train.add(temp); } for (Feature f : features) { temp = new ArrayList<>(); temp.add((double) f._classLabel); temp.addAll(f._features); train.add(temp); } for (Feature f : features) { temp = new ArrayList<>(); temp.add((double) f._classLabel); temp.addAll(f._features); train.add(temp); } for (Feature f : features) { temp = new ArrayList<>(); temp.add((double) f._classLabel); temp.addAll(f._features); train.add(temp); } long seed = System.nanoTime(); Collections.shuffle(train, new Random(seed)); svmTrain(train); // Printing labels to check printModelLabels(); writeModeltoFile(obj); }