/// <summary> Builds the tree structure with hold out set
		/// 
		/// </summary>
		/// <param name="train">the data for which the tree structure is to be
		/// generated.
		/// </param>
		/// <param name="test">the test data for potential pruning
		/// </param>
		/// <param name="keepData">is training Data to be kept?
		/// </param>
		/// <exception cref="Exception">if something goes wrong
		/// </exception>
		public virtual void  buildTree(Instances train, Instances test, bool keepData)
		{
			
			Instances[] localTrain, localTest;
			int i;
			
			if (keepData)
			{
				m_train = train;
			}
			m_isLeaf = false;
			m_isEmpty = false;
			m_sons = null;
			m_localModel = m_toSelectModel.selectModel(train, test);
			m_test = new Distribution(test, m_localModel);
			if (m_localModel.numSubsets() > 1)
			{
				localTrain = m_localModel.split(train);
				localTest = m_localModel.split(test);
				train = test = null;
				m_sons = new ClassifierTree[m_localModel.numSubsets()];
				for (i = 0; i < m_sons.Length; i++)
				{
					m_sons[i] = getNewTree(localTrain[i], localTest[i]);
					localTrain[i] = null;
					localTest[i] = null;
				}
			}
			else
			{
				m_isLeaf = true;
				if (Utils.eq(train.sumOfWeights(), 0))
					m_isEmpty = true;
				train = test = null;
			}
		}
		/// <summary> Builds the tree structure.
		/// 
		/// </summary>
		/// <param name="data">the data for which the tree structure is to be
		/// generated.
		/// </param>
		/// <param name="keepData">is training data to be kept?
		/// </param>
		/// <exception cref="Exception">if something goes wrong
		/// </exception>
		public virtual void  buildTree(Instances data, bool keepData)
		{
			
			Instances[] localInstances;
			
			if (keepData)
			{
				m_train = data;
			}
			m_test = null;
			m_isLeaf = false;
			m_isEmpty = false;
			m_sons = null;
			m_localModel = m_toSelectModel.selectModel(data);
			if (m_localModel.numSubsets() > 1)
			{
				localInstances = m_localModel.split(data);
				data = null;
				m_sons = new ClassifierTree[m_localModel.numSubsets()];
				for (int i = 0; i < m_sons.Length; i++)
				{
					m_sons[i] = getNewTree(localInstances[i]);
					localInstances[i] = null;
				}
			}
			else
			{
				m_isLeaf = true;
				if (Utils.eq(data.sumOfWeights(), 0))
					m_isEmpty = true;
				data = null;
			}
		}