Java Code Examples for weka.core.SerializationHelper#write()
The following examples show how to use
weka.core.SerializationHelper#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecisionTree.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) throws Exception { Classifier j48 = new J48(); Instances trainingData = GenerateTestVessels.getData(); j48.buildClassifier(trainingData); System.out.println(j48); double[] vesselUnderTest = GenerateTestVessels.getBarco(5); DenseInstance inst = new DenseInstance(1.0,vesselUnderTest); inst.setDataset(trainingData); inst.setClassMissing(); System.out.println(inst); double result = j48.classifyInstance(inst); System.out.println(GenerateTestVessels.types[(int)result]); SerializationHelper.write(new FileOutputStream("tmp"), j48); J48 j48Read = (J48)SerializationHelper.read(new FileInputStream("tmp")); }
Example 2
Source File: RelExTool.java From Criteria2Query with Apache License 2.0 | 5 votes |
public static void saveModel(Classifier classifier, String modelName) { try { SerializationHelper.write(modelName, classifier); } catch (Exception e) { e.printStackTrace(); } }
Example 3
Source File: Serialized.java From meka with GNU General Public License v3.0 | 5 votes |
/** * Stores the given statistics. * * @param stats the statistics to store * @return null if successfully stored, otherwise error message */ @Override public String write(List<EvaluationStatistics> stats) { log("Writing " + stats.size() + " statistics to: " + m_File); try { SerializationHelper.write(m_File.getAbsolutePath(), stats); return null; } catch (Exception e) { return handleException("Failed to write statistics to: " + m_File, e); } }
Example 4
Source File: SerializedExperiment.java From meka with GNU General Public License v3.0 | 5 votes |
/** * Writes and experiment to disk. * * @param exp the experiment to save * @param file the file to save to * @return null if successful, otherwise error message */ @Override public String write(Experiment exp, File file) { String result; result = null; try { SerializationHelper.write(file.getAbsolutePath(), exp); } catch (Exception e) { result = handleException("Failed to write experiment to: " + file, e); } return result; }
Example 5
Source File: MLPlanCLI.java From AILibs with GNU Affero General Public License v3.0 | 4 votes |
private static void serializeModel(final CommandLine commandLine, final ISupervisedLearner bestClassifier) throws Exception { SerializationHelper.write(commandLine.getOptionValue(modelFileOption, modelFile), bestClassifier); }