public void serialize(Path output, Configuration conf) throws IOException {
FileSystem fs = output.getFileSystem(conf);
FSDataOutputStream out = fs.create(new Path(output, "naiveBayesModel.bin"));
try {
out.writeFloat(alphaI);
VectorWritable.writeVector(out, weightsPerFeature);
VectorWritable.writeVector(out, weightsPerLabel);
VectorWritable.writeVector(out, perlabelThetaNormalizer);
for (int row = 0; row < weightsPerLabelAndFeature.numRows(); row++) {
VectorWritable.writeVector(out, weightsPerLabelAndFeature.viewRow(row));