/*
 * Encog(tm) Core v3.3 - Java Version
 * http://www.heatonresearch.com/encog/
 * https://github.com/encog/encog-java-core
 
 * Copyright 2008-2014 Heaton Research, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *   
 * For more information on Heaton Research copyrights, licenses 
 * and trademarks visit:
 * http://www.heatonresearch.com/copyright
 */
package org.encog.ensemble.bagging;

import java.util.ArrayList;

import org.encog.ensemble.Ensemble;
import org.encog.ensemble.EnsembleAggregator;
import org.encog.ensemble.EnsembleML;
import org.encog.ensemble.EnsembleMLMethodFactory;
import org.encog.ensemble.EnsembleTrainFactory;
import org.encog.ensemble.EnsembleTypes;
import org.encog.ensemble.EnsembleTypes.ProblemType;
import org.encog.ensemble.data.factories.ResamplingDataSetFactory;

public class Bagging extends Ensemble {

	private int splits;

	public Bagging(int splits, int dataSetSize, EnsembleMLMethodFactory mlFactory, EnsembleTrainFactory trainFactory, EnsembleAggregator aggregator)
	{
		this.dataSetFactory = new ResamplingDataSetFactory(dataSetSize);
		this.splits = splits;
		this.mlFactory = mlFactory;
		this.trainFactory = trainFactory;
		this.members = new ArrayList<EnsembleML>();
		this.aggregator = aggregator;
		initMembers();
	}

	@Override
	public void initMembers()
	{
		this.initMembersBySplits(this.splits);
	}

	@Override
	public ProblemType getProblemType() {
		return EnsembleTypes.ProblemType.CLASSIFICATION;
	}

	@Override
	public EnsembleML getMember(int memberNumber) {
		return members.get(memberNumber);
	}

	public void trainStep() {
		for (EnsembleML current : members)
		{
			current.trainStep();
		}
	}


}

@@ -1245,16 +1245,81 @@
 emType;%0A
+import org.encog.ensemble.data.factories.EnsembleDataSetFactory;%0A
 import o
@@ -1512,33 +1512,36 @@
 ctory mlFactory,
- 
+%0A%09%09%09
 EnsembleTrainFac
@@ -1603,67 +1603,319 @@
 this
-.dataSetFactory = new ResamplingDataSetFactory(dataSetSize)
+(splits,dataSetSize,mlFactory,trainFactory,aggregator,new ResamplingDataSetFactory(dataSetSize));%0A%09%7D%0A%09%0A%09public Bagging(int splits, int dataSetSize, EnsembleMLMethodFactory mlFactory, %0A%09%09%09EnsembleTrainFactory trainFactory, EnsembleAggregator aggregator, EnsembleDataSetFactory edf)%0A%09%7B%0A%09%09this.dataSetFactory = edf
 ;%0A%09%09
@@ -2096,24 +2096,25 @@
 mbers();%0A%09%7D%0A
+%09
 %0A%09@Override%0A

Allow a different dataset factory to be passed in