instance.setWeight(-instance.weight());
	public double kFoldCV(BayesNet bayesNet, int nNrOfFolds) throws Exception {		m_BayesNet = bayesNet;		double fAccuracy = 0.0;		double fWeight = 0.0;		Instances instances = bayesNet.m_Instances;		// estimate CPTs based on complete data set		bayesNet.estimateCPTs();		int nFoldStart = 0;		int nFoldEnd = instances.numInstances() / nNrOfFolds;		int iFold = 1;		while (nFoldStart < instances.numInstances()) {			// remove influence of fold iFold from the probability distribution			for (int iInstance = nFoldStart; iInstance < nFoldEnd; iInstance++) {				Instance instance = instances.instance(iInstance);				instance.setWeight(-instance.weight());				bayesNet.updateClassifier(instance);			}						// measure accuracy on fold iFold			for (int iInstance = nFoldStart; iInstance < nFoldEnd; iInstance++) {				Instance instance = instances.instance(iInstance);				instance.setWeight(-instance.weight());				fAccuracy += accuracyIncrease(instance);				fWeight += instance.weight();			}			// restore influence of fold iFold from the probability distribution			for (int iInstance = nFoldStart; iInstance < nFoldEnd; iInstance++) {				Instance instance = instances.instance(iInstance);				instance.setWeight(-instance.weight());				bayesNet.updateClassifier(instance);			}			// go to next fold			nFoldStart = nFoldEnd;			iFold++;			nFoldEnd = iFold * instances.numInstances() / nNrOfFolds;		}		return fAccuracy / fWeight;	} // kFoldCV