/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); write(out, table); }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); write(out, table); }
/** * Writes the binary representation of this learned function to the location specified by * {@link #lcFilePath}. If {@link #lcFilePath} is not set, this method will produce an error * message and exit the program. **/ public void saveModel() { if (lcFilePath == null) { System.err.println("LBJava ERROR: saveModel() called without a cached location"); new Exception().printStackTrace(); System.exit(1); } ExceptionlessOutputStream out = ExceptionlessOutputStream.openCompressedStream(lcFilePath); write(out); out.close(); }
/** * Writes this algorithm's internal representation as text. * * @param out The output stream. **/ public void write(PrintStream out) { out.println(name); if (rounds > 0) { out.print(alpha[0]); for (int i = 1; i < rounds; ++i) out.print(", " + alpha[i]); out.println(); } else out.println("---"); out.println(weakLearner.getClass().getName()); weakLearner.write(out); for (int i = 0; i < rounds; ++i) { weakLearners[i].setLexicon(lexicon); weakLearners[i].write(out); weakLearners[i].setLexicon(null); } }
public static void main(String[] args) { String learnerName = null; try { learnerName = args[0]; if (args.length > 1) throw new Exception(); } catch (Exception e) { System.err .println("usage: java edu.illinois.cs.cogcomp.lbjava.learn.LearnerToText <learner>"); System.exit(1); } Learner learner = ClassUtils.getLearner(learnerName); learner.demandLexicon(); PrintStream out = new PrintStream(new BufferedOutputStream(System.out)); learner.write(out); out.close(); } }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); weakLearner.write(out); out.writeInt(rounds); for (int i = 0; i < rounds; ++i) weakLearners[i].write(out); for (int i = 0; i < rounds; ++i) out.writeDouble(alpha[i]); out.writeString(allowableValues[0]); out.writeString(allowableValues[1]); }
/** * Writes only the learned function's model (which includes the label lexicon) to the specified * file in binary form. This file is then cached in {@link #lcFilePath}. * * @param filename The name of the file in which to write the model. **/ public void writeModel(String filename) { ExceptionlessOutputStream out = ExceptionlessOutputStream.openCompressedStream(filename); write(out); out.close(); try { lcFilePath = new URL("file:" + filename); } catch (Exception e) { System.err.println("Error constructing URL:"); e.printStackTrace(); System.exit(1); } }
super.write(out); out.writeBoolean(trained);
super.write(out); out.writeBoolean(trained);
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); out.writeDouble(learningRate); out.writeDouble(bias); weightVector.write(out); }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); out.writeString(defaultPrediction); baseLearner.write(out); int N = network.size(); out.writeInt(N); int M = 0; for (int i = 0; i < N; ++i) if (network.get(i) != null) ++M; out.writeInt(M); for (int i = 0; i < N; ++i) { Learner learner = (Learner) network.get(i); if (learner != null) { out.writeInt(i); learner.write(out); } } }
public TestReal(Learner classifier, Classifier oracle, Parser parser) { int examples = 0; double totalDifference = 0; double[] actuals = {}; double[] predictions = {}; classifier.write(System.out); for (Object example = parser.next(); example != null; example = parser.next()) { double prediction = classifier.realValue(example); predictions = Arrays.copyOf(predictions, predictions.length + 1); predictions[predictions.length - 1] = prediction; double value = oracle.realValue(example); actuals = Arrays.copyOf(actuals, actuals.length + 1); actuals[actuals.length - 1] = value; double difference = Math.abs(prediction - value); totalDifference += difference; classifier.classify(example); ++examples; System.out.println("Example " + examples + " difference: " + difference + " (prediction: " + prediction + ")"); } System.out.println("test examples number: " + examples); double avg = totalDifference / examples; System.out.println("Average difference: " + avg); double p = getPearsonCorrelation(predictions, actuals); System.out.println("Pearson correlation:" + p); SpearmansCorrelation e = new SpearmansCorrelation(); double sp = e.correlation(predictions, actuals); System.out.println("Spearman correlation:" + sp); }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); int N = network.size(); out.writeInt(N); for (int i = 0; i < N; ++i) ((BiasedRandomWeightVector) network.get(i)).write(out); }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); out.writeDouble(smoothing); int N = network.size(); out.writeInt(N); for (int i = 0; i < N; ++i) ((NaiveBayesVector) network.get(i)).write(out); }
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); baseLTU.write(out); out.writeBoolean(conjunctiveLabels); int N = network.size(); out.writeInt(N); for (int i = 0; i < N; ++i) { LinearThresholdUnit ltu = (LinearThresholdUnit) network.get(i); if (ltu == null) out.writeString(null); else ltu.write(out); } out.close(); }
Learner learner = (Learner) learners.get(indexes[i]); learner.setLexicon(lexicon); learner.write(out); learner.setLexicon(null);
/** * Writes the learned function's internal representation in binary form. * * @param out The output stream. **/ public void write(ExceptionlessOutputStream out) { super.write(out); if (allowableValues == null) out.writeInt(0); else { out.writeInt(allowableValues.length); for (int i = 0; i < allowableValues.length; ++i) out.writeString(allowableValues[i]); } out.writeDouble(initialWeight); out.writeDouble(threshold); out.writeDouble(learningRate); out.writeDouble(positiveThickness); out.writeDouble(negativeThickness); out.writeDouble(bias); weightVector.write(out); }
super.write(out); out.writeString(solverType); out.writeDouble(C);