Added subsample to use only a percentage of the input data.