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

Method main

src/com/winvector/logistic/LogisticScore.java:80–123  ·  view source on GitHub ↗

@param args @throws IOException @throws FileNotFoundException @throws ClassNotFoundException @throws URISyntaxException @throws ParseException @throws SQLException

(String[] args)

Source from the content-addressed store, hash-verified

78 * @throws SQLException
79 */
80 public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException, URISyntaxException, ParseException, SQLException {
81 final Log log = LogFactory.getLog(LogisticScore.class);
82 log.info("start LogisticScore\t" + new Date());
83 final CommandLine cl = parseCommandLine(args);
84 final File modelFile = new File(cl.getOptionValue(MODELKEY));
85 final File resultFile = new File(cl.getOptionValue(RESULTFILEKEY));
86 log.info("cwd: " + new File(".").getAbsolutePath());
87 log.info("reading model: " + modelFile.getAbsolutePath());
88 final ObjectInputStream ois = new ObjectInputStream(new FileInputStream(modelFile));
89 final Model model = (Model)ois.readObject();
90 ois.close();
91 log.info("model:\n" + model.config.formatSoln(model.coefs));
92 DBHandle handle = null;
93 Statement stmt = null;
94 final Iterable<BurstMap> testSource;
95 if(cl.getOptionValue(DATAURIKEY)!=null) {
96 final URI trainURI = new URI(cl.getOptionValue(DATAURIKEY));
97 log.info(" source URI: " + trainURI.toString());
98 char sep = '\t';
99 if(cl.getOptionValue(DATASEP)!=null) {
100 sep = cl.getOptionValue(DATASEP).charAt(0);
101 }
102 testSource = new TrivialReader(trainURI,sep,null,false,null, false);
103 } else {
104 final URI dbProps = new URI(cl.getOptionValue(DATAHDLKEY));
105 final String dbTable = cl.getOptionValue(DATATBLKEY);
106 handle = DBUtil.buildConnection(dbProps, true);
107 stmt = handle.conn.createStatement();
108 log.info(" source db: " + handle);
109 testSource = DBIterable.buildSource(handle, stmt, dbTable, model.origFormula.allTerms());
110 log.info(" query: " + testSource);
111 }
112 log.info("scoring data: " + testSource);
113 score(model,testSource,resultFile);
114 if(null!=stmt) {
115 stmt.close();
116 stmt = null;
117 }
118 if(null!=handle) {
119 handle.conn.close();
120 handle = null;
121 }
122 log.info("done LogisticScore\t" + new Date());
123 }
124
125 // can load into DB and get marginals with SQL like: select MODEL_CHOSEN_OUTCOME,RATING,COUNT(1) from scored1 group by MODEL_CHOSEN_OUTCOME,RATING
126 public static double score(final Model model, final Iterable<BurstMap> testSource, final File resultFile) throws FileNotFoundException, IOException, ClassNotFoundException {

Callers

nothing calls this directly

Calls 5

parseCommandLineMethod · 0.95
scoreMethod · 0.95
formatSolnMethod · 0.80
allTermsMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected