/** * deserializes the content of the file and returns it, null if an error * occurred. * * @param filename the name of the file to deserialize * @return the deserialized content, null if problem occurred */ public static Object loadFromFile(String filename) { Object result; try { result = SerializationHelper.read(filename); } catch (Exception e) { result = null; } return result; }
/** * deserializes the content of the file and returns it, null if an error * occurred. * * @param filename the name of the file to deserialize * @return the deserialized content, null if problem occurred */ public static Object loadFromFile(String filename) { Object result; try { result = SerializationHelper.read(filename); } catch (Exception e) { result = null; } return result; }
public Classifier[] readModels(File[] modelFiles) throws Exception { if (modelFiles == null || modelFiles.length == 0) { return new Classifier[0]; } Classifier[] classList = new Classifier[modelFiles.length]; for (int i = 0; i < classList.length; i++) { classList[i] = (Classifier) SerializationHelper.read(modelFiles[i].getAbsolutePath()); } return classList; } }
/** * loads the serialized model if necessary, throws an Exception if the * derserialization fails. * * @throws Exception if deserialization fails */ protected void initModel() throws Exception { if (m_Model == null) { m_Model = (Classifier) SerializationHelper.read(m_ModelFile .getAbsolutePath()); } }
/** * deserializes the given file and returns the object from it. * * @param filename the file to deserialize from * @return the deserialized object * @throws Exception if deserialization fails */ public static Object read(String filename) throws Exception { return read(new FileInputStream(filename)); }
/** * loads the serialized model if necessary, throws an Exception if the * derserialization fails. * * @throws Exception if deserialization fails */ protected void initModel() throws Exception { if (m_Model == null) { m_Model = (Classifier) SerializationHelper.read(m_ModelFile .getAbsolutePath()); } }
/** * deserializes the given file and returns the object from it. * * @param filename the file to deserialize from * @return the deserialized object * @throws Exception if deserialization fails */ public static Object read(String filename) throws Exception { return read(new FileInputStream(filename)); }
private void loadClassifier() throws Exception { cls = (Classifier) weka.core.SerializationHelper .read(new File(tcModelLocation, MODEL_CLASSIFIER).getAbsolutePath()); }
private void loadClassifier() throws Exception { cls = (Classifier) weka.core.SerializationHelper .read(new File(tcModelLocation, MODEL_CLASSIFIER).getAbsolutePath()); }
public List<String> predict(Instances data, File model) throws Exception { Classifier cls = (Classifier) SerializationHelper.read(model.getAbsolutePath()); return performPrediction(cls, data); }
public List<String> predict(Instances data, File model) throws Exception { Classifier cls = (Classifier) SerializationHelper.read(model.getAbsolutePath()); return performPrediction(cls, data); }
public List<String> predict(Instances data, File model) throws Exception { MultiLabelClassifier cls = (MultiLabelClassifier) SerializationHelper .read(model.getAbsolutePath()); return performPrediction(cls, data); }
public List<String> predict(Instances data, File model) throws Exception { MultiLabelClassifier cls = (MultiLabelClassifier) SerializationHelper .read(model.getAbsolutePath()); return performPrediction(cls, data); }
@Override public void loadClassifierModel(File path) throws ClassifierException { if (!path.exists()) { throw new ClassifierException("Unable to load trained classifier model; Model file " + path.toString() + " does not exist"); } try { classifier = (AbstractClassifier) weka.core.SerializationHelper.read(path.getAbsolutePath()); } catch (Exception e) { } modelReady = true; }
/** * Load a Weka model (classifier) from a file * @param filename complete path and file name * @return classifier */ public static AbstractClassifier readClassifier(String filename) { AbstractClassifier cls = null; // deserialize model try { cls = (AbstractClassifier) SerializationHelper.read(filename); } catch (Exception e) { IJ.log("Error when loading classifier from " + filename); e.printStackTrace(); } return cls; }
/** * Reads an experiment from disk. * * @param file the file to load * @return the experiment, null if failed to load */ @Override public Experiment read(File file) { try { return (Experiment) SerializationHelper.read(file.getAbsolutePath()); } catch (Exception e) { handleException("Failed to read experiment from: " + file, e); return null; } }
/** * Reads the statistics. * * @return the statistics that were read */ @Override public List<EvaluationStatistics> read() { List<EvaluationStatistics> result; try { result = (List<EvaluationStatistics>) SerializationHelper.read(m_File.getAbsolutePath()); } catch (Exception e) { result = null; handleException("Failed to read serialized statistics from: " + m_File, e); } return result; }
/** * Reads the statistics. * * @return the statistics that were read */ @Override public List<EvaluationStatistics> read() { List<EvaluationStatistics> result; try { result = (List<EvaluationStatistics>) SerializationHelper.read(m_File.getAbsolutePath()); } catch (Exception e) { result = null; handleException("Failed to read serialized statistics from: " + m_File, e); } return result; }
/** * Reads an experiment from disk. * * @param file the file to load * @return the experiment, null if failed to load */ @Override public Experiment read(File file) { try { return (Experiment) SerializationHelper.read(file.getAbsolutePath()); } catch (Exception e) { handleException("Failed to read experiment from: " + file, e); return null; } }
/** * Load a Weka model (classifier) from a file * @param filename complete path and file name * @return classifier */ public static AbstractClassifier readClassifier(String filename) { AbstractClassifier cls = null; // deserialize model try { cls = (AbstractClassifier) SerializationHelper.read(filename); } catch (Exception e) { IJ.log("Error when loading classifier from " + filename); e.printStackTrace(); } return cls; }