MCPcopy Create free account
hub / github.com/WinVector/Logistic / MapRedAccuracy

Class MapRedAccuracy

src/com/winvector/logistic/mr/MapRedAccuracy.java:33–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import com.winvector.variables.VariableEncodings;
32
33public final class MapRedAccuracy {
34 private static final String MRFIELDNAME = "MapRedAc.MRBlock";
35 public static final long NGOODFIELD = 0;
36 public static final long NSEENFIELD = 1;
37 private final SigmoidLossMultinomial underlying;
38 private final WritableVariableList defs;
39 private final boolean useIntercept;
40 private final Configuration mrConfig;
41 private final Path pathIn;
42 private final String tmpPrefix;
43
44
45 public MapRedAccuracy(final SigmoidLossMultinomial underlying, final WritableVariableList defs, final boolean useIntercept,
46 final String tmpPrefix, final Configuration mrConfig, final Path pathIn) {
47 this.underlying = underlying;
48 this.useIntercept = useIntercept;
49 this.defs = defs;
50 this.pathIn = pathIn;
51 this.mrConfig = mrConfig;
52 this.tmpPrefix = tmpPrefix;
53 }
54
55
56 public static final class AccuracyMapper extends Mapper<LongWritable,Text,LongWritable,LongWritable> {
57 private LineBurster burster = null;
58 // config
59 private JobStateDescr config = null;
60 // derived
61 private VariableEncodings defs = null;
62 private Log log = null;
63 private String hostDescr = null;
64 // result
65 private long nGood = 0;
66 private long nSeen = 0;
67
68 @Override
69 public void setup(final Context context) throws IOException {
70 log = LogFactory.getLog(AccuracyMapper.class);
71 hostDescr = WritableUtils.hostDescr();
72 log.info(".setup() " + hostDescr);
73 // read side-channel configuration
74 try {
75 burster = SerialUtils.readSerialiazlabeFromString(context.getConfiguration().get(MapRedScan.BURSTERSERFIELD));
76 } catch (ClassNotFoundException e) {
77 throw new IOException(e.toString());
78 }
79 config = JobStateDescr.fromString(context.getConfiguration().get(MRFIELDNAME));
80 defs = new VariableEncodings(config.defs,config.useIntercept,config.weightKey);
81 nGood = 0;
82 nSeen = 0;
83 }
84
85 @Override
86 public void map(final LongWritable key, final Text value, final Context context) {
87 final String origStr = value.toString();
88 final BurstMap parsed = burster.parse(origStr);
89 if(!parsed.isEmpty()) {
90 final SparseSemiVec v = defs.vector(parsed);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected