/**
* {@inheritDoc}
*/
@Override
public final void save(final OutputStream os, final Object obj) {
final EncogWriteHelper out = new EncogWriteHelper(os);
final SVM svm2 = (SVM) obj;
out.addSection("SVM");
out.addSubSection("PARAMS");
out.addProperties(svm2.getProperties());
out.addSubSection("SVM-PARAM");
out.writeProperty(PersistConst.INPUT_COUNT, svm2.getInputCount());
out.writeProperty(PersistSVM.PARAM_C, svm2.getParams().C);
out.writeProperty(PersistSVM.PARAM_CACHE_SIZE,
svm2.getParams().cache_size);
out.writeProperty(PersistSVM.PARAM_COEF0, svm2.getParams().coef0);
out.writeProperty(PersistSVM.PARAM_DEGREE, svm2.getParams().degree);
out.writeProperty(PersistSVM.PARAM_EPS, svm2.getParams().eps);
out.writeProperty(PersistSVM.PARAM_GAMMA, svm2.getParams().gamma);
out.writeProperty(PersistSVM.PARAM_KERNEL_TYPE,
svm2.getParams().kernel_type);
out.writeProperty(
PersistSVM.PARAM_NUM_WEIGHT, svm2.getParams().nr_weight);
out.writeProperty(PersistSVM.PARAM_NU, svm2.getParams().nu);
out.writeProperty(PersistSVM.PARAM_P, svm2.getParams().p);
out.writeProperty(PersistSVM.PARAM_PROBABILITY,
svm2.getParams().probability);
out.writeProperty(PersistSVM.PARAM_SHRINKING,
svm2.getParams().shrinking);
out.writeProperty(PersistSVM.PARAM_SVM_TYPE, svm2.getParams().svm_type);
out.writeProperty(PersistSVM.PARAM_WEIGHT, svm2.getParams().weight);
out.writeProperty(PersistSVM.PARAM_WEIGHT_LABEL,
svm2.getParams().weight_label);
if (svm2.getModel() != null) {
out.addSubSection("SVM-MODEL");
try {
final ByteArrayOutputStream ba = new ByteArrayOutputStream();
final DataOutputStream das = new DataOutputStream(ba);
svm.svm_save_model(das, svm2.getModel());
out.write(ba.toString("UTF-8"));
das.close();
ba.close();
} catch (final IOException ex) {
throw new PersistError(ex);
}
}
out.flush();
}