.


:




:

































 

 

 

 


18. 18.1, : I = 2.225




18.1, : I = 2.225

IreE(size) 1,5422, Gain(size) = 0.7503

Info(size) - 0.979S, GainRatio(size) = 0.7503/0.9799

- 0.7657 Ires(holes) = 0.9675, Gain[holes> = 1.324 Info(holes) = 1.5546, GainRatio(holes) = 0.8517

18.2. Gain = I - ires

I - - (p(D) log p{D) + p(~D) log p(~D)>

= - (0.25 log C.25 + 0.75 log 0.75) - 0.6113 Ires p(S), p(~S), p(DIS), p[D(-S) p(S) = p(S[D> p<D) + p(SI~D) p(~D) - 0.75 * 0.25

+ 1/6 * 0.75 - 0.3125 :

p(D|S) - ptD) p(SID) / p[S> - 0.25 * 0.75 / 0.3125 = 0.6 p(~D|S! =0.4 plD|-S> = p(D)*p(~5|D) / p(~S) = 0.25 * 0.25 / (1-0.3125)

= 0.09090 Ires = p(S)*I(D|S> + p(~S}*I(D|~S) = 0.6056 I(D|S) , . Gain = 0.2057 GainRatio - GainiS) / I(S) - 0.2057/0.860 == 0.2296

18.5. % prunetree(Tree, PrunedTcee): PrunedTree

i Tree,

%

%

% , :

% Tree = leaf(Mode, ClassFreguencyListi

% Tree = tree(Root, LeftSubtree, RightSubtree)

prunetree(Tree, PrunedTree):-

prune(Tree, PrunedTree, Ecror, FreguencyList). I prune(Tree PrunedTree, Error, FreguencyList): % PeunedTree Tree, I % % , a FreguencyList - % Tree prune (leaf(Node, FregList), leafi Node, FregList), Error, FregL.ist):-

static_error(FregList, Error). prune(tree! Root, Left, Right}, PrunedT, Error, FregList):-

prune(Left, Leftl, LeftEcror, LeftFreg),

prune! Right, Rightl, RightError, RightFreg),

sijmlists! LeftFreg, RightFreg, FregList), %

%

static_error(FregList, StaticErr),

sum{ LeftFreg, N1),

suml RightFreg, K2),

BackedErr is (N1 * LeftError + H2 * RightError) / (Ml + H2),

decide! StaticErr, EackedErr, Root, FregList, Leftl, Rightl, Error, PrunedT). % , ,




\ :

decide! S tatErr, BackErr, Root, FreqL, _, _, StatErr,

leaf(Root, FreqLM:-

StatErr < BackErr,!. % : % % : decide) _, BackErr, Root, _, Left, Right, BackErr,

treet Root, Left, Right)). % static_error[ ClassFrequencyList, Error): i , static_error(FreqList, Error):-

max[ FreqList, Max), I I FreqList

sum (FreqList, All), $ FreqList

number_of_classes(NumClasses),

Error is (All - Max + NumClasses - 1) / { All + NuraClassesl. sum{[],0). suiffl [Number I Numbers], Sum):-

sural Numbers, Suml),

Sum is Suml + Number. max< [X], X). max([X,Y I List], Max):-

X > YE!, max([X I List], Max)

maxt [Y I List!, Max). sumlistsm, [],[)]-

sumlistst (XI I LI]. 1X2! L2], [X3 I L3]):-

X3 is XI + X2,

suralistst LI, L2, L3). % treel(tree(a, i

tree(br leaf(e, [3,2]), leaf(f, [1,0])), %

%

treet , tree' d, leaf! g, [1,1}), leaf! h, 10,1])}, leaf! i, [1,0])))). rauaber_of_classea (2). % : %?- treel(Tree), prunetree) Tree, PrunedTree).





:


: 2015-10-01; !; : 342 |


:

:

, .
==> ...

1410 - | 1351 -


© 2015-2024 lektsii.org - -

: 0.009 .