You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am training a model using Random Forest classification algorithm. The algorithm is working fine producing the model. but it is failing to serialize the model to disk. I have tried multiple versions of JDK (11, 17, 22) and the result has been the same.
Expected behavior
I expect that the model gets serialized to disk using Java's serialization. I want to load that model later on in order to run queries against it.
Actual behavior
Exception in thread "main" java.io.NotSerializableException: smile.data.type.ObjectType$$Lambda$18/0x00007e9cd8cef840
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1369)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1165)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1369)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1165)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345)
at smile.io.Write.object(Write.java:58)
at com.*.machinelearning.SmileRandomForestTrainer.main(SmileRandomForestTrainer.java:74)
Code snippet
// Load the Parquet file
DataFrame data = Read.csv(trainingDataPath, CSVFormat.DEFAULT.withFirstRecordAsHeader().withRecordSeparator(','));
// Define formula for the model
Formula formula = Formula.lhs("target_hit");
// Set up properties for Random Forest
Properties props = new Properties();
props.setProperty("numTrees", "100");
props.setProperty("maxDepth", "23");
props.setProperty("minSamplesSplit", "2");
props.setProperty("minSamplesLeaf", "1");
props.setProperty("randomState", "11");
// Train the Random Forest model
RandomForest rf = RandomForest.fit(formula, data, props);
// write the model to filesystem
Write.object(rf, Path.of(outputModelPath));
LOG.info("Model trained and saved to: {}", outputModelPath);
Describe the bug
I am training a model using Random Forest classification algorithm. The algorithm is working fine producing the model. but it is failing to serialize the model to disk. I have tried multiple versions of JDK (11, 17, 22) and the result has been the same.
Expected behavior
I expect that the model gets serialized to disk using Java's serialization. I want to load that model later on in order to run queries against it.
Actual behavior
Exception in thread "main" java.io.NotSerializableException: smile.data.type.ObjectType$$Lambda$18/0x00007e9cd8cef840
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1369)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1165)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1369)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1165)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1543)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1500)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1423)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345)
at smile.io.Write.object(Write.java:58)
at com.*.machinelearning.SmileRandomForestTrainer.main(SmileRandomForestTrainer.java:74)
Code snippet
// Load the Parquet file
DataFrame data = Read.csv(trainingDataPath, CSVFormat.DEFAULT.withFirstRecordAsHeader().withRecordSeparator(','));
Input data
Additional context
openjdk version "22.0.2" 2024-07-16
OpenJDK Runtime Environment Corretto-22.0.2.9.1 (build 22.0.2+9-FR)
OpenJDK 64-Bit Server VM Corretto-22.0.2.9.1 (build 22.0.2+9-FR, mixed mode, sharing)
Amazon Linux - EC2 in AWS.
Running with Smile 3.1.1 verison.
The text was updated successfully, but these errors were encountered: