public CRFClassifierEvaluator(String description, CRFClassifier<IN> classifier, Collection<List<IN>> data, List<Triple<int[][][], int[], double[][][]>> featurizedData) { this.description = description; this.classifier = classifier; this.data = data; this.featurizedData = featurizedData; cmd = getCmd(cmdStr); saveOutput = true; }
/** * Set the evaluation command (set to null to skip evaluation using command line) * @param evalCmd */ public void setEvalCmd(String evalCmd) { log.info("setEvalCmd to " + evalCmd); this.cmdStr = evalCmd; if (cmdStr != null) { cmdStr = cmdStr.trim(); if (cmdStr.isEmpty()) { cmdStr = null; } } cmd = getCmd(cmdStr); }
@Override public double evaluate(double[] x) { double score; // initialized below setValues(x); if (getCmd() != null) { evaluateCmd(getCmd()); score = interpretCmdOutput(); } else { try { // TODO: Classify in memory instead of writing to tmp file File f = File.createTempFile("CRFClassifierEvaluator","txt"); f.deleteOnExit(); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(f)); PrintWriter pw = IOUtils.encodedOutputStreamPrintWriter(outputStream, null, true); classifier.classifyAndWriteAnswers(data, featurizedData, pw, classifier.makeReaderAndWriter()); outputStream.close(); BufferedReader br = new BufferedReader(new FileReader(f)); MultiClassChunkEvalStats stats = new MultiClassChunkEvalStats("O"); score = stats.score(br, "\t"); log.info(stats.getConllEvalString()); f.delete(); } catch (Exception ex) { throw new RuntimeException(ex); } } return score; }
public CRFClassifierEvaluator(String description, CRFClassifier<IN> classifier, Collection<List<IN>> data, List<Triple<int[][][], int[], double[][][]>> featurizedData) { this.description = description; this.classifier = classifier; this.data = data; this.featurizedData = featurizedData; cmd = getCmd(cmdStr); saveOutput = true; }
public CRFClassifierEvaluator(String description, CRFClassifier<IN> classifier, Collection<List<IN>> data, List<Triple<int[][][], int[], double[][][]>> featurizedData) { this.description = description; this.classifier = classifier; this.data = data; this.featurizedData = featurizedData; cmd = getCmd(cmdStr); saveOutput = true; }
public CRFClassifierEvaluator(String description, CRFClassifier<IN> classifier, CRFLogConditionalObjectiveFunction func, Collection<List<IN>> data, List<Pair<int[][][], int[]>> featurizedData) { this.description = description; this.classifier = classifier; this.func = func; this.data = data; this.featurizedData = featurizedData; cmd = getCmd(cmdStr); }
/** * Set the evaluation command (set to null to skip evaluation using command line) * @param evalCmd */ public void setEvalCmd(String evalCmd) { this.cmdStr = evalCmd; if (cmdStr != null) { cmdStr = cmdStr.trim(); if (cmdStr.length() == 0) { cmdStr = null; } } cmd = getCmd(cmdStr); }
/** * Set the evaluation command (set to null to skip evaluation using command line) * @param evalCmd */ public void setEvalCmd(String evalCmd) { System.err.println("setEvalCmd to " + evalCmd); this.cmdStr = evalCmd; if (cmdStr != null) { cmdStr = cmdStr.trim(); if (cmdStr.length() == 0) { cmdStr = null; } } cmd = getCmd(cmdStr); }
/** * Set the evaluation command (set to null to skip evaluation using command line) * @param evalCmd */ public void setEvalCmd(String evalCmd) { log.info("setEvalCmd to " + evalCmd); this.cmdStr = evalCmd; if (cmdStr != null) { cmdStr = cmdStr.trim(); if (cmdStr.isEmpty()) { cmdStr = null; } } cmd = getCmd(cmdStr); }
public double evaluate(double[] x) { double score = 0; setValues(x); if (getCmd() != null) { evaluateCmd(getCmd()); } else { try { // TODO: Classify in memory instead of writing to tmp file File f = File.createTempFile("CRFClassifierEvaluator","txt"); f.deleteOnExit(); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(f)); classifier.classifyAndWriteAnswers(data, featurizedData, outputStream, classifier.makeReaderAndWriter()); outputStream.close(); BufferedReader br = new BufferedReader(new FileReader(f)); MultiClassChunkEvalStats stats = new MultiClassChunkEvalStats("O"); score = stats.score(br, "\t"); System.err.println(stats.getConllEvalString()); f.delete(); } catch (Exception ex) { throw new RuntimeException(ex); } } return score; }
public double evaluate(double[] x) { double score = 0; setValues(x); if (getCmd() != null) { evaluateCmd(getCmd()); score = interpretCmdOutput(); } else { try { // TODO: Classify in memory instead of writing to tmp file File f = File.createTempFile("CRFClassifierEvaluator","txt"); f.deleteOnExit(); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(f)); PrintWriter pw = IOUtils.encodedOutputStreamPrintWriter(outputStream, null, true); classifier.classifyAndWriteAnswers(data, featurizedData, pw, classifier.makeReaderAndWriter()); outputStream.close(); BufferedReader br = new BufferedReader(new FileReader(f)); MultiClassChunkEvalStats stats = new MultiClassChunkEvalStats("O"); score = stats.score(br, "\t"); System.err.println(stats.getConllEvalString()); f.delete(); } catch (Exception ex) { throw new RuntimeException(ex); } } return score; }
@Override public double evaluate(double[] x) { double score; // initialized below setValues(x); if (getCmd() != null) { evaluateCmd(getCmd()); score = interpretCmdOutput(); } else { try { // TODO: Classify in memory instead of writing to tmp file File f = File.createTempFile("CRFClassifierEvaluator","txt"); f.deleteOnExit(); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(f)); PrintWriter pw = IOUtils.encodedOutputStreamPrintWriter(outputStream, null, true); classifier.classifyAndWriteAnswers(data, featurizedData, pw, classifier.makeReaderAndWriter()); outputStream.close(); BufferedReader br = new BufferedReader(new FileReader(f)); MultiClassChunkEvalStats stats = new MultiClassChunkEvalStats("O"); score = stats.score(br, "\t"); log.info(stats.getConllEvalString()); f.delete(); } catch (Exception ex) { throw new RuntimeException(ex); } } return score; }