⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stats.cpp

📁 计算机人工智能方面的决策树方法 c4.5
💻 CPP
字号:
/*************************************************************************/
/*                                                                       */
/*  Statistical routines for C4.5                                        */
/*  -----------------------------                                        */
/*                                                                       */
/*************************************************************************/


#include "defns.h"
#include "c45types.h"
#include "extern.h"

									
/*************************************************************************/
/*                                                                       */
/*  Compute the additional errors if the error rate increases to the     */
/*  upper limit of the confidence level.  The coefficient is the         */
/*  square of the number of standard deviations corresponding to the     */
/*  selected confidence level.  (Taken from Documenta Geigy Scientific   */
/*  Tables (Sixth Edition), p185 (with modifications).)                  */
/*                                                                       */
/*************************************************************************/


double Val[] = { 0,  0.001, 0.005, 0.01, 0.05, 0.10, 0.20, 0.40, 1.00},
      Dev[] = {100,   3.09,  2.58,  2.33, 1.65, 1.28, 0.84, 0.25, 0.00};


double AddErrs(ItemCount N, ItemCount e)
/*    -------  */
{
    static double Coeff=0;
    double Val0, Pr;

    if ( ! Coeff )
    {
	/*  Compute and retain the coefficient value, interpolating from
	    the values in Val and Dev  */

	int i;

	i = 0;
	while ( CF > Val[i] ) i++;

	Coeff = Dev[i-1] +
		  (Dev[i] - Dev[i-1]) * (CF - Val[i-1]) /(Val[i] - Val[i-1]);
	Coeff = Coeff * Coeff;
    }

    if ( e < 1E-6 )
    {
	return (double)(N * (1 - exp(log(CF) / N)));
    }
    else
    if ( e < 0.9999 )
    {
	Val0 = (double)(N * (1 - exp(log(CF) / N)));
	return (double)(Val0 + e * (AddErrs(N, 1.0) - Val0));
    }
    else
    if ( e + 0.5 >= N )
    {
	return (double)(0.67 * (N - e));
    }
    else
    {
	Pr = (double)((e + 0.5 + Coeff/2
		+ sqrt(Coeff * ((e + 0.5) * (1 - (e + 0.5)/N) + Coeff/4)) )
	     / (N + Coeff));
	return (double)(N * Pr - e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -