我在从 sdcard 加载保存的模型时遇到问题。在 Weka 的官方 wiki 中,我发现了 2 种反序列化模型的方法,但它们都不适用于 Android。
//First Method
RandomForest rf = (RandomForest) weka.core.SerializationHelper.
read(Environment.getExternalStorageDirectory().getPath() + "/BC.model");
//Second Method
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
Environment.getExternalStorageDirectory().getPath() + "/BC.model"));
RandomForest rf = new RandomForest();
rf = (RandomForest) ois.readObject();
我在 logcat 中收到此错误:
java.io.InvalidClassException:
weka.classifiers.trees.RandomForest; Incompatible class (SUID):
weka.classifiers.trees.RandomForest