Skip to content

Instantly share code, notes, and snippets.

View xuwenhao's full-sized avatar
🎯
Focusing

Xu Wenhao xuwenhao

🎯
Focusing
View GitHub Profile
@xuwenhao
xuwenhao / gist:3985764
Created October 31, 2012 08:09
Pig Code to use UDF of accumulator interface
raw_data = load 'data' using ... as (model:chararray, ctr:double, clicks:int);
A = FOREACH raw_data GENERATE model as model, ctr as pctr, ((clicks > 0) ? 1 : 0) as clicked;
B = GROUP A by model;
C = FOREACH B {
D = ORDER A by pctr asc;
GENERATE com.mediav.ml.AccurateAuc(D.clicked);
}
STORE C INTO 'xxxx';