@Override
	public void train(List<Instance> instances) {
		// initialize w values
		for (Instance instance : instances) {
			for (Entry<Integer, Double> entry : instance.getFeatureVector().getVector().entrySet()) {
				linearParam.add(entry.getKey(), 0.0);
			}
		}
		
		int iter = 0;
		while (iter < iters) {
			iter ++;
			for (Instance instance : instances) {
				double y = Double.valueOf(instance.getLabel().toString()) * 2.0 - 1.0; // get label
				double loss = y * MathUtilities.innerProduct(linearParam, instance);
				if ( loss < 1) {
					double tau = (1.0 -loss) / MathUtilities.innerProduct(instance.getFeatureVector(), instance);
					for (Entry<Integer, Double> entry : instance.getFeatureVector().getVector().entrySet()) {
						int key = entry.getKey();
						linearParam.add(key, linearParam.get(key) + tau * y * instance.getFeatureVector().get(key));
					}
				}
			}
		}
		
		
	}