Beispiel #1
0
void spliterrorsetVL(CMyAln * pALN) // routine
{
	// assign the square errors on the validation set to the leaf nodes of the ALN
	double * adblX = (double *) malloc((nDim) * sizeof(double));
	double desired = 0;
	double predict = 0;
  double      se = 0; // square error added to LFN DBLSQERRORVAL
	ALNNODE* pActiveLFN;
	for(int j=0; j<nRowsALNinputValFile; j++)   // this is expensive using the whole validation set, but more accurate
  {
    for(int i=0; i<nDim; i++)
		{
			adblX[i] = ALNinputValFile.GetAt(j,i,0); // the value at nDim - 1 is used only for desired
		}
		desired = adblX[nDim - 1];
		adblX[nDim - 1] = 0; // not used by QuickEval WWA 2009.10.06
		predict = pALN->QuickEval(adblX, &pActiveLFN);
    se = (predict - desired) * (predict - desired);
		(pActiveLFN->DATA.LFN.pSplit)->nCount++;
		(pActiveLFN->DATA.LFN.pSplit)->DBLSQERRORVAL += se;
  } // end loop over VLfile
	free(adblX);
} // END of spliterrorsetVL
Beispiel #2
0
void spliterrorsetTR(CMyAln * pALN) // routine
{
	// assign the square errors on the validation set to the leaf nodes of the ALN
	double * adblX = (double *) malloc((nDim) * sizeof(double));
	double desired = 0;
	double predict = 0;
  double      se = 0; // square error accumulator
	ALNNODE* pActiveLFN;
	for(int j=0; j<nRowsTR; j++)
	{
		for(int i=0; i<nDim; i++)
		{
			adblX[i] = TRfile.GetAt(j,i,0);
		}
		desired = adblX[nDim - 1]; // get the desired result
		adblX[nDim-1] = 0; // not used in evaluation by QuickEval
		predict = pALN->QuickEval(adblX, &pActiveLFN);
    se = (predict - desired) * (predict - desired);
		(pActiveLFN->DATA.LFN.pSplit)->nCount++;
		(pActiveLFN->DATA.LFN.pSplit)->dblSqError += se;
  } // end loop over TRset
	free(adblX);
} // END of spliterrorsetTR