Диссертация (1137066), страница 17
Текст из файла (страница 17)
smpl<−sample ( row . names ( d [ d [ , t a r g e t ] <= l g d . t h r e s h o l d , ] ) , s i z e = 1 0 0 ). G l o b a l E n v $ t e s t . smpl<−sample ( row . names ( d[−which ( row . names ( d )%i n%c ( pos . smpl , neg .smpl ) ) , ] ) , s i z e = 5 0 ). G l o b a l E n v $ pos . d a t a<−d [ . G l o b a l E n v $ pos . smpl ,− which ( names ( d ) == t a r g e t ) ].
G l o b a l E n v $ neg . d a t a<−d [ . G l o b a l E n v $ neg . smpl ,− which ( names ( d ) == t a r g e t ) ]. G l o b a l E n v $ t e s t . d a t a<−d [ . G l o b a l E n v $ t e s t . smpl , ]. G l o b a l E n v $ pos . l g d<− . G l o b a l E n v $ d [ pos . smpl , t a r g e t ]. G l o b a l E n v $ neg . l g d<− .
G l o b a l E n v $ d [ neg . smpl , t a r g e t ]. G l o b a l E n v $minmax . t a b l e<− n o r m a l i z e ( r b i n d ( pos . data , neg . d a t a ) ). G l o b a l E n v $ g i n i . t a b l e<−d a t a . frame ( s u b s a m p l e . s i z e =0 , num_ i t e r =0 , g i n i =0 , pos .
c n t .avg =0 , neg . c n t . avg =0 , r e j e c t s =0 , a l p h a . t h r e s h o l d =0 , v o t i n g = " h a h a h a " , w e i g h t .a l p h a =FALSE , s t r i n g s A s F a c t o r s = FALSE ) [ − 1 , ]}#GO!p r e p a r e . data ( lgd . t h r e s h o l d = 0 . 9 )for ( alpha in c ( 0 . 0 1 , 0 . 0 5 , 0 . 1 ) ) {for ( subsample . s i z e in c ( 0 . 0 2 , 0 .
0 3 , 0 . 0 5 , 0 . 1 ) ) {f o r ( num_ i t e r i n c ( 1 0 0 , 5 0 0 , 1 0 0 0 ) ) {system . time ( l a z i f i e r ( subsample . s i z e, num_ i t e r , a l p h a , v o t i n g = " c o u n t " ) )}}}for ( alpha in c ( 0 . 0 1 , 0 . 0 5 , 0 . 1 ) ) {for ( subsample . s i z e in c ( 0 . 0 2 , 0 .
0 3 , 0 . 0 5 , 0 . 1 ) ) {f o r ( num_ i t e r i n c ( 1 , 5 , 1 0 ) ) {for ( vote in c ( " count " , " perim " , " perim with count " ) ) {f o r ( b o o l i n c (TRUE , FALSE ) ) {l a z i f i e r ( subsample . s i z e, num_ i t e r , a l p h a , v o t i n g = v o t e , w e i g h t . a l p h a =98bool )}}}}}l a z i f i e r ( 0 . 0 2 , 10 , 0.01 , v o t i n g =" count " )pos .
d a t a = t r [ t r $ t a r g e t ==1 , imp . v a r s ]neg . d a t a = t r [ t r $ t a r g e t ==0 , imp . v a r s ]t e s t . d a t a = v l [ , c ( imp . v a r s , " t a r g e t " ) ]l a z i f i e r <− f u n c t i o n ( s u b s a m p l e . s i z e , num_ i t e r , a l p h a , v o t i n g = " p e r i m w i t h c o u n t " ,w e i g h t . a l p h a =FALSE ) {p r e d . m a t r i x<−d a t a .
frame ( i d = " 1234567890 " , v o t i n g = " h a h a h a " , w e i g h t . a l p h a =FALSE , p .c n t =0 , n . c n t =0 , margin =0 , nrow . neg =0 , nrow . pos =0 , c n t . pos . h y p o s =0 , c n t . neg . h y p o s=0 , s t r i n g s A s F a c t o r s = FALSE ) [ − 1 , ]f o r ( i i n 1 : nrow ( . G l o b a l E n v $ t e s t . d a t a ) ) {l p<− l a z y . p r e d i c t ( gnew = i , unknown . d a t a = . G l o b a l E n v $ t e s t . d a t a [ , rem ( names ( t e s t. d a t a ) , .
G l o b a l E n v $ t a r g e t ) ] , pos . d a t a = pos . d a t a [ , rem ( names ( pos . d a t a ) , .G l o b a l E n v $ t a r g e t ) ] , neg . d a t a = neg . d a t a [ , rem ( names ( neg . d a t a ) , . G l o b a l E n v $t a r g e t ) ] , s u b s a m p l e .
s i z e = s u b s a m p l e . s i z e , num_ i t e r s = num_ i t e r , a l p h a = a l p h a ,voting =voting , weight . alpha=weight . alpha )p r e d . m a t r i x [ nrow ( p r e d . m a t r i x ) + 1 , ]<− l p [ [ 2 ] ]}p r e d . m a t r i x $ t a r g e t <− . G l o b a l E n v $ t e s t . d a t a [ , . G l o b a l E n v $ t a r g e t ]g i n i .
t a b l e [ nrow ( g i n i . t a b l e ) + 1 , ] <<−c ( s u b s a m p l e . s i z e ,num_ i t e r ,# r o c ( x=−p r e d . m a t r i x $ margin , t a r g e t =p r e d .matrix $ target ) $ gini ,g i n i . c a l c ( x=−p r e d . m a t r i x $ margin , y = p r e d .m a t r i x $ t a r g e t ) $AR,mean ( p r e d . m a t r i x $ c n t . pos .
h y p o s ) ,mean ( p r e d . m a t r i x $ c n t . neg . h y p o s ) ,sum ( p r e d . m a t r i x $ c n t . neg . h y p o s ==0 & p r e d .99m a t r i x $ c n t . pos . h y p o s ==0) / nrow ( p r e d .matrix ) ,alpha . t h r e s h o l d =alpha ,voting=voting ,weight . alpha=weight . alpha )l o o k .
l p <<− l p. GlobalEnv $ pred . matrix = pred . matrixp r i n t ( c ( s u b s a m p l e . s i z e , num_ i t e r , a l p h a , v o t i n g , w e i g h t . a l p h a , a s . c h a r a c t e r ( Sys. time ( ) ) ) )}l a z i f i e r ( s u b s a m p l e . s i z e = 0 . 0 2 , num_ i t e r = 3 0 , a l p h a = 0 . 0 5 , v o t i n g = " p e r i m " ,w e i g h t . a l p h a = TRUE)100.