*/
@Override
public final Object read(final InputStream is) {
final SVM result = new SVM();
final EncogReadHelper in = new EncogReadHelper(is);
EncogFileSection section;
while ((section = in.readNextSection()) != null) {
if (section.getSectionName().equals("SVM")
&& section.getSubSectionName().equals("PARAMS")) {
final Map<String, String> params = section.parseParams();
result.getProperties().putAll(params);
}
if (section.getSectionName().equals("SVM")
&& section.getSubSectionName().equals("SVM-PARAM")) {
final Map<String, String> params = section.parseParams();
result.setInputCount(EncogFileSection.parseInt(params,
PersistConst.INPUT_COUNT));
result.getParams().C = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_C);
result.getParams().cache_size = EncogFileSection.parseDouble(
params, PersistSVM.PARAM_CACHE_SIZE);
result.getParams().coef0 = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_COEF0);
result.getParams().degree = EncogFileSection.parseInt(params,
PersistSVM.PARAM_DEGREE);
result.getParams().eps = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_EPS);
result.getParams().gamma = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_GAMMA);
result.getParams().kernel_type = EncogFileSection.parseInt(
params, PersistSVM.PARAM_KERNEL_TYPE);
result.getParams().nr_weight = EncogFileSection.parseInt(
params, PersistSVM.PARAM_NUM_WEIGHT);
result.getParams().nu = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_NU);
result.getParams().p = EncogFileSection.parseDouble(params,
PersistSVM.PARAM_P);
result.getParams().probability = EncogFileSection.parseInt(
params, PersistSVM.PARAM_PROBABILITY);
result.getParams().shrinking = EncogFileSection.parseInt(
params, PersistSVM.PARAM_SHRINKING);
result.getParams().svm_type = EncogFileSection.parseInt(params,
PersistSVM.PARAM_SVM_TYPE);
result.getParams().weight = EncogFileSection.parseDoubleArray(
params, PersistSVM.PARAM_WEIGHT);
result.getParams().weight_label = EncogFileSection
.parseIntArray(params, PersistSVM.PARAM_WEIGHT_LABEL);
} else if (section.getSectionName().equals("SVM")
&& section.getSubSectionName().equals("SVM-MODEL")) {
try {
final StringReader rdr = new StringReader(
section.getLinesAsString());
final BufferedReader br = new BufferedReader(rdr);
final svm_model model = svm.svm_load_model(br);
result.setModel(model);
br.close();
rdr.close();