public void filter(DataSet data) {
		logger.debug("filtering most common features");
		int max = 0;
		for (int i = 0; i < allFeatures.size(); i++) {
			if (allFeatures.get(i).freq > max)
				max = allFeatures.get(i).freq;
		}
		for (int i = allFeatures.size() - 1; i >= 0; i--) {
			if (allFeatures.get(i).freq > 0.5 * max) {
				featureNames.remove(allFeatures.get(i).name);
				allFeatures.remove(i);
			}
		}
		Hashtable<Integer, Integer> old2new = new Hashtable<Integer, Integer>();
		for (int i = 0; i < allFeatures.size(); i++) {
			old2new.put(allFeatures.get(i).id, i);
			allFeatures.get(i).id = i;
		}

		for (Instance inst : data.getInstances()) {
			for (int i = inst.length() - 1; i >= 0; i--) {
				if (!old2new.containsKey(inst.getFeatureIndex().get(i))) {
					inst.removeAt(i);
				} else {
					inst.setIndex(i, old2new.get(inst.getIndex(i)));
				}
			}
		}
		totalNum = allFeatures.size();
		logger.debug("after filtering " + allFeatures.size());
	}