in liblinear-addon/src/main/java/LiblinearModel.java [170:195]
public void serialize(OutputStream out) throws IOException {
try (DataOutputStream ds = new DataOutputStream(out);
ByteArrayOutputStream modelBytes = new ByteArrayOutputStream()) {
Linear.saveModel(new OutputStreamWriter(modelBytes, LIBLINEAR_MODEL_ENCODING), model);
ds.writeInt(modelBytes.size());
ds.write(modelBytes.toByteArray());
// write string array
// write label count
ds.writeInt(outcomeLabels.length);
// write each label
for (String outcomeLabel : outcomeLabels) {
ds.writeUTF(outcomeLabel);
}
// write entry count
ds.writeInt(predMap.size());
for (Map.Entry<String, Integer> entry : predMap.entrySet()) {
ds.writeUTF(entry.getKey());
ds.writeInt(entry.getValue());
}
}
}