wli*_*ner 5 java persistence bayesian
有没有人坚持为CI-Bayes训练?我有来自这个网站的示例代码:http://www.theserverside.com/news/thread.tss?thread_id = 49773
这是代码:
FisherClassifier fc=new FisherClassifierImpl();
fc.train("The quick brown fox jumps over the lazy dog's tail","good");
fc.train("Make money fast!", "bad");
String classification=fc.getClassification("money", "unknown"); // should be "bad"
Run Code Online (Sandbox Code Playgroud)
所以我需要能够将训练集存储在本地文件中.
有没有人曾经这样做过?
小智 0
要将 java 对象持久保存在本地文件中,该对象必须首先实现 Serialized 接口。
import java.io.Serializable;
public class MyClass implements Serializable {...
Run Code Online (Sandbox Code Playgroud)
然后,您想要保留此训练集的类应包含如下方法:
public void persistTrainingSet(FisherClassifier fc) {
String outputFile = <path/to/output/file>;
try {
FileOutputStream fos = new FileOutputStream(outputFile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(fc);
oos.close();
}
catch (IOException e) {
//handle exception
}
finally {
//do any cleaning up
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
396 次 |
| 最近记录: |