亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? prunerule.c

?? 數(shù)據(jù)挖掘c4.5算法(vc語(yǔ)言版本)歡迎大家下載測(cè)試!!!!
?? C
字號(hào):
/*************************************************************************/
/*								   	 */
/*	Pruning single rules					   	 */
/*	--------------------				   	      	 */
/*								   	 */
/*************************************************************************/


#include "defns.i"
#include "types.i"
#include "extern.i"
#include "rulex.i"


/*  External data structures used in building rules  */

extern ItemNo	*TargetClassFreq,	/* [Boolean] */
		*Errors,		/* [Condition] */
		*Total;			/* [Condition] */

extern float	*Pessimistic,		/* [Condition] */
		*Actual,		/* [Condition] */
		*CondSigLevel;		/* [Condition] */

extern Boolean	**CondSatisfiedBy,	/* [Condition][ItemNo] */
		*Deleted;

#define Before(n1,n2)  (n1->Tested < n2->Tested ||\
			n1->NodeType < n2->NodeType ||\
		        n1->Tested == n2->Tested && n1->Cut < n2->Cut)

#define IsTarget(case)  (Class(case) == TargetClass ? 1 : 0)



/*************************************************************************/
/*									 */
/*  Prune the rule given by the conditions Cond, and the number of	 */
/*  conditions NCond, and add the resulting rule to the current		 */
/*  ruleset if it is sufficiently accurate				 */
/*									 */
/*************************************************************************/


    PruneRule(Cond, NCond, TargetClass)
/*  ---------  */
    Condition Cond[];
    short NCond;
    ClassNo TargetClass;
{
    short d, dd, id, Bestd, Bestid, Remaining=NCond;
    float DefaultError, Extra, AddErrs(), TableProb();
    Boolean Alter, Satisfies(), NewRule(), Redundant();
    Condition Hold;
    ItemNo i;

    ForEach(d, 0, NCond)
    {
	Deleted[d] = false;
    }

    /*  Evaluate the satisfaction matrix  */

    TargetClassFreq[0] = TargetClassFreq[1] = 0;

    ForEach(i, 0, MaxItem)
    {
	ForEach(d, 1, NCond)
	{
	    CondSatisfiedBy[d][i] = Satisfies(Item[i], Cond[d]);
	}
	TargetClassFreq[IsTarget(Item[i])]++;
    }

    DefaultError = 1.0 - (TargetClassFreq[true] + 1.0) / (MaxItem + 3.0);

    /*  Find conditions to delete  */

    Verbosity(1) printf("\n  pruning rule for %s", ClassName[TargetClass]);

    do
    {
	Alter = false;

	FindTables(NCond, TargetClass);

	/*  Find the condition, deleting which would most improve
	    the accuracy of the rule.
	    Notes: The pessimistic error rate, and not the actual
		   error rate, is currently used.
	    	   When d is 0, we are dealing with all conditions.  */

	Bestd = id = 0;

	Verbosity(1)
	    printf("\n     Err Used   Pess\tAbsent condition\n");

	ForEach(d, 0, NCond)
	{
	    if ( Deleted[d] ) continue;

	    if ( Total[d] )
	    {
		Actual[d] = Errors[d] / (float) Total[d];
		Extra = AddErrs((float) Total[d], (float) Errors[d]);
		Pessimistic[d] = (Errors[d] + Extra) / Total[d];
	    }
	    else
	    {
		Actual[d] = 0;
		Pessimistic[d] = DefaultError;
	    }

	    Verbosity(1)
		printf("   %5d%5d  %4.1f%%",
		       Errors[d], Total[d], 100 * Pessimistic[d]);

	    if ( ! d )
	    {
		Verbosity(1) printf("\t<base rule>\n");
	    }
	    else
	    {
		id++;

		/*  If significance testing option used, invoke Fisher's
		    exact test here to assess probability that division
		    by d arises from chance.  */

		if ( SIGTEST )
		{
		    CondSigLevel[d] =
			TableProb(Errors[0],
				   Errors[d]-Errors[0],
				   Total[0]-Errors[0],
			           Total[d]-Total[0]-Errors[d]+Errors[0]);

		    Verbosity(1) printf("  Sig=%.3f", CondSigLevel[d]);
		}

		Verbosity(1) PrintCondition(Cond[d]);

		/*  Bestd identifies the condition with lowest pessimistic
		    error  estimate  */

		if ( ! Bestd || Pessimistic[d] <= Pessimistic[Bestd] )
		{
		    Bestd = d;
		    Bestid = id;
		}

		/*  Alter is set true if we are going to drop a condition
		    (either because we get lower pessimistic est, or
		    because one of the conditions fails a significance test)  */

		if ( Pessimistic[d] <= Pessimistic[0] ||
		     Actual[d] <= Actual[0]  ||
		     SIGTEST && CondSigLevel[d] > SIGTHRESH )
		{
		    Alter = true;
		}
	    }
	}

	if ( Alter )
	{
	    Verbosity(1) printf("\teliminate test %d\n", Bestid);

	    Deleted[Bestd] = true;
	    Remaining--;
	}

    } while ( Alter && Remaining );

    if ( ! Remaining || ! Total[0] )
    {
	return;
    }

    if ( Pessimistic[0] >= DefaultError )
    {
	Verbosity(1) printf("\ttoo inaccurate\n");
	return;
    }

    /*  Sort the conditions  */

    ForEach(d, 1, Remaining)
    {
	dd =  0;
	ForEach(id, d, NCond)
	{
	    if ( ! Deleted[id] &&
		 ( ! dd ||
		   Before(Cond[id]->CondTest, Cond[dd]->CondTest) ) )
	    {
		dd = id;
	    }
	}
	if ( dd != d )
	{
	    Hold    = Cond[d];
	    Cond[d] = Cond[dd];
	    Cond[dd] = Hold;
	    Deleted[dd] = Deleted[d];
	}
	Deleted[d] = true;
    }

    NewRule(Cond, Remaining, TargetClass, Pessimistic[0]);
}



/*************************************************************************/
/*									 */
/*  See whether condition R is redundant                           	 */
/*									 */
/*************************************************************************/


Boolean Redundant(R, Cond, NCond)
/*      ---------  */
    Condition Cond[];
    short R, NCond;
{
    short d, v, vv;
    Test t, Rt;
    Boolean IsSubset();

    Rt = Cond[R]->CondTest;
    v =  Cond[R]->TestValue;

    ForEach(d, 1, NCond)
    {
	if ( Deleted[d] || d == R ) continue;

	t = Cond[d]->CondTest;
	vv = Cond[d]->TestValue;

	if ( t->Tested != Rt->Tested ) continue;

	switch ( t->NodeType )
	{
	    case BrDiscr:  /* test of discrete attribute */

		return false;

	    case ThreshContin:  /* test of continuous attribute */

		if ( vv == v &&
		     ( v == 1 ? t->Cut < Rt->Cut : t->Cut > Rt->Cut ) )
		{
		    return true;
		}

		break;

	    case BrSubset:  /* subset test on discrete attribute  */

		if ( IsSubset(t->Subset[vv], Rt->Subset[v], Rt->Tested) )
		{
		    return true;
		}
	}
    }

    return false;
}



/*************************************************************************/
/*									 */
/*  Decide whether subset S1 of values is contained in subset S2	 */
/*									 */
/*************************************************************************/


Boolean IsSubset(S1, S2, Att)
/*      --------  */
    Set S1, S2;
    Attribute Att;
{
    DiscrValue v;

    ForEach(v, 1, MaxAttVal[Att])
    {
	if ( In(v, S1) && ! In(v, S2) ) return false;
    }

    return true;
}



/*************************************************************************/
/*									 */
/*  Find the frequency distribution tables for the current conditions: 	 */
/*									 */
/*	Total[0] = items matching all conditions		   	 */
/*	Total[d] = items matching all except condition d	   	 */
/*									 */
/*	Errors[0] = wrong-class items matching all conditions	   	 */
/*	Errors[d] = wrong-class items matching all but cond d	   	 */
/*									 */
/*  This routine is critical to the efficiency of rule pruning. It	 */
/*  computes the information above in one pass through the data,	 */
/*  looking at cases that fail to satisfy at most one of the		 */
/*  non-deleted conditions						 */
/*									 */
/*************************************************************************/


    FindTables(NCond, TargetClass)
/*  -----------  */
    short NCond;
    ClassNo TargetClass;
{
    ItemNo i;
    short Misses, Missed[2], d;
    Boolean CorrectClass;

    /*  Clear distributions  */

    ForEach(d, 0, NCond)
    {
	Total[d] = Errors[d] = 0;
    }

    /*  Set distributions  */

    ForEach(i, 0, MaxItem)
    {
	Misses = 0;
	CorrectClass = IsTarget(Item[i]);

	for ( d = 1 ; d <= NCond && Misses <= 1 ; d++ )
	{
	    if ( ! Deleted[d] && ! CondSatisfiedBy[d][i] )
	    {
		Missed[Misses++] = d;
	    }
	}

	if ( ! Misses )
	{
	    UpdateCount(Total, Errors, 0, CorrectClass);
	}
	else
	if ( Misses == 1 )
	{
	    UpdateCount(Total, Errors, Missed[0], CorrectClass);
	}
    }

    /*  Adjust counts to reflect cases that met all conditions  */

    ForEach(d, 1, NCond)
    {
	if ( ! Deleted[d] )
	{
	    Total[d] += Total[0];
	    Errors[d] += Errors[0];
	}
    }
}



/*************************************************************************/
/*									 */
/*  Increment the counts Total[d] and Errors[d]				 */
/*									 */
/*************************************************************************/


    UpdateCount(T, E, d, OK)
/*  -----------  */
    ItemNo T[], E[];
    short d;
    Boolean OK;
{
    T[d]++;
    if ( ! OK ) E[d]++;
}



/*************************************************************************/
/*									 */
/*  Determine whether the given case description satisfies the given	 */
/*  condition.								 */
/*									 */
/*************************************************************************/


Boolean Satisfies(CaseDesc, OneCond)
/*      ---------  */
    Description CaseDesc; 
    Condition OneCond;
{
    DiscrValue v;
    float cv;
    Test t;
    short s;
    Boolean Outcome;

    t = OneCond->CondTest;

    /*  Determine the outcome of this test on this item  */

    switch ( t->NodeType )
    {
	case BrDiscr:  /* test of discrete attribute */

	    v = DVal(CaseDesc, t->Tested);
	    Outcome = ( v == 0 ? -1 : v );
	    break;

	case ThreshContin:  /* test of continuous attribute */

	    cv = CVal(CaseDesc, t->Tested);
	    Outcome = ( cv == Unknown ? -1 : cv <= t->Cut ? 1 : 2 );
	    break;

	case BrSubset:  /* subset test on discrete attribute  */

	    v = DVal(CaseDesc, t->Tested);
	    Outcome = -1;
	    ForEach(s, 1, t->Forks)
	    {
		if ( In(v, t->Subset[s]) )
		{
		    Outcome = s;
		    break;
		}
	    }
    }

    return ( Outcome == OneCond->TestValue );
}



/*************************************************************************/
/*									 */
/*  Hypergeometric distribution	(uses tabulated log factorials)		 */
/*									 */
/*************************************************************************/


double Hypergeom(a, r, A, B)
/*               ---------  */
    int a, r, A, B;
{
    return exp( LogFact[A] + LogFact[B] + LogFact[r] + LogFact[A+B-r] -
	        ( LogFact[a] + LogFact[r-a] + LogFact[A-a]
		  + LogFact[B-(r-a)] + LogFact[A+B]) );
}



/*************************************************************************/
/*									 */
/*  TableProb examines the 2x2 contingency table t and computes the      */
/*  probability that a random division could have produced a split at	 */
/*  least as extreme as this.  Also known as "Fisher's Exact Test",	 */
/*  after its inventor, R.A. Fisher.					 */
/*									 */
/*************************************************************************/


float TableProb(t11, t12, t21, t22)
/*    ---------  */
    int t11, t12, t21, t22;
{
    double Sum=0.0;
    int A, B, r, a, k, a0;

    /*  First, rearrange the rows and columns of the table to get it into
	canonical form  */

    if ( t11 + t12 > t21 + t22 )
    {
	A = t11 + t12;
	B = t21 + t22;

	if ( t11 * (t21 + t22) > t21 * (t11 + t12) )
	{
	    a0 = t11;
	    r  = t11 + t21;
	}
	else
	{
	    a0 = t12;
	    r  = t12 + t22;
	}
    }
    else
    {
	A = t21 + t22;
	B = t11 + t12;
	if ( t21 * (t11 + t12) > t11 * (t21 + t22) )
	{
	    a0 = t21;
	    r  = t21 + t11;
	}
	else
	{
	    a0 = t22;
	    r  = t22 + t12;
	}
    }

    /*  Now compute the probability  */

    k = Min(r, A);
    ForEach(a, a0, k)
    {
	Sum += Hypergeom(a, r, A, B);
    }

    return Sum;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av一二三| 欧美美女bb生活片| 国产精品久久久久久久久果冻传媒 | 热久久久久久久| 精品国偷自产国产一区| 高清国产一区二区| 亚洲综合一区二区| 精品国产三级a在线观看| 日韩精品一区二区三区视频 | 日韩欧美专区在线| 91伊人久久大香线蕉| 三级欧美韩日大片在线看| 欧美国产日韩在线观看| 678五月天丁香亚洲综合网| 成人精品视频一区二区三区尤物| 亚洲国产欧美另类丝袜| 国产精品三级av| 日韩免费电影一区| 久久综合九色综合97婷婷女人| 一区二区三区中文在线观看| 欧美精品视频www在线观看| 这里只有精品电影| 久久色视频免费观看| 日本一区二区高清| 一区二区三区四区av| 天天综合色天天| 夜夜爽夜夜爽精品视频| 偷窥少妇高潮呻吟av久久免费| 老司机精品视频导航| 亚洲综合小说图片| 老司机精品视频在线| 成人免费观看av| 欧美午夜不卡视频| 99久久er热在这里只有精品66| 国产美女娇喘av呻吟久久| 亚洲高清免费在线| 久久成人av少妇免费| eeuss鲁片一区二区三区在线看| 国产精品88888| 精品无人码麻豆乱码1区2区| 人人狠狠综合久久亚洲| 成人在线视频一区| 欧美日韩中文一区| 欧美日韩性生活| 久久久国产精华| 久久综合色鬼综合色| 亚洲乱码国产乱码精品精的特点| 中文欧美字幕免费| 亚洲va欧美va人人爽| 无吗不卡中文字幕| 成人永久看片免费视频天堂| 欧美日韩一区二区在线观看| 亚洲国产精华液网站w| 亚洲不卡一区二区三区| 成人免费视频网站在线观看| 91精品国产色综合久久ai换脸| 制服丝袜亚洲播放| 国产精品久久精品日日| 日本欧美一区二区| 日本高清成人免费播放| 色综合久久综合| 91久久精品网| 国产网站一区二区| 国产精品伦理一区二区| 免费在线欧美视频| 国产精品三级电影| 蜜桃传媒麻豆第一区在线观看| 日韩成人一级大片| 91在线精品秘密一区二区| 精品国产麻豆免费人成网站| 亚洲一级在线观看| 成人午夜大片免费观看| 欧美va天堂va视频va在线| 久久蜜桃一区二区| 日本伊人色综合网| 欧美性色黄大片手机版| 亚洲天堂网中文字| 亚洲成人午夜电影| 色综合久久久久综合体桃花网| 久久―日本道色综合久久| 日韩电影免费在线看| 欧美日韩一区小说| 亚洲精品中文在线观看| av一二三不卡影片| 国产欧美精品一区二区三区四区 | 蜜臀av亚洲一区中文字幕| 91成人在线观看喷潮| 亚洲男人的天堂av| 日韩av在线发布| 欧美日韩亚洲另类| 亚洲电影视频在线| 欧美性猛交一区二区三区精品| 亚洲精品亚洲人成人网在线播放| 99精品视频一区| 国产精品动漫网站| 不卡视频在线看| 欧美一级黄色大片| 日本美女视频一区二区| 欧美一级片免费看| 日本亚洲最大的色成网站www| 91麻豆精品国产91久久久久久久久| 亚洲一区二区五区| 欧美日韩综合色| 婷婷久久综合九色国产成人| 欧美精品在线观看播放| 青青国产91久久久久久 | 亚洲欧洲精品成人久久奇米网| 免费美女久久99| 日韩欧美一级片| 国产伦理精品不卡| 国产精品视频线看| 99精品视频一区二区三区| 一区二区日韩电影| 欧美日韩电影一区| 亚洲免费在线视频| 欧美日韩国产综合草草| 秋霞午夜av一区二区三区| 2023国产精品| 成人福利在线看| 亚洲精品成人a在线观看| 欧美日韩第一区日日骚| 久久国产乱子精品免费女| 久久色.com| 91麻豆免费观看| 天天av天天翘天天综合网| 午夜欧美电影在线观看| 欧美一区二区精品| 国产精品羞羞答答xxdd| 中文字幕亚洲在| 欧美男人的天堂一二区| 久久99精品久久久久婷婷| 欧美韩国日本一区| 精品视频一区二区不卡| 美女视频第一区二区三区免费观看网站| 精品免费视频一区二区| www.在线欧美| 丝袜亚洲精品中文字幕一区| 26uuu国产电影一区二区| 不卡av在线网| 午夜精品国产更新| 久久久.com| 欧美三级资源在线| 国产精品资源网| 一级特黄大欧美久久久| 精品国产a毛片| 欧美在线观看一区二区| 一区二区国产盗摄色噜噜| 日韩欧美一区电影| 91亚洲男人天堂| 另类成人小视频在线| 亚洲人成伊人成综合网小说| 91精品国产综合久久久蜜臀粉嫩| 高清在线观看日韩| 亚洲成人在线免费| 中文字幕免费一区| 日韩一区二区麻豆国产| 99精品偷自拍| 国产精品一区二区在线看| 午夜视频一区在线观看| 国产精品三级视频| 精品毛片乱码1区2区3区| 91成人看片片| 成人免费视频免费观看| 蜜桃一区二区三区四区| 亚洲线精品一区二区三区八戒| 国产日韩欧美a| 91精品国产全国免费观看| 中文字幕免费不卡| 日韩女同互慰一区二区| 欧美日韩精品三区| 91免费观看视频在线| 国产成都精品91一区二区三| 麻豆精品在线视频| 亚洲午夜精品17c| 国产精品三级电影| 欧美精品一区二区久久久| 欧美福利电影网| 欧洲国内综合视频| eeuss影院一区二区三区| 国内精品国产成人| 自拍偷拍亚洲激情| 久久伊99综合婷婷久久伊| 欧美久久一二区| 欧美性xxxxxxxx| 色综合天天天天做夜夜夜夜做| 中文字幕在线不卡视频| 精品久久免费看| 日韩欧美中文一区| 欧美一级精品大片| 欧美精品久久天天躁| 欧美日韩在线直播| 欧美午夜精品理论片a级按摩| 色欧美日韩亚洲| av动漫一区二区| 99热在这里有精品免费| 成人h动漫精品| 99国产精品一区| 色综合久久久久综合99| 99精品偷自拍| 在线观看av不卡|