Closed michaellavelle closed 8 years ago
Hi @michaellavelle, this may not be a bug. In general, using PredictorReader and PredictorWriter is the recommended way to read and write models. I rely on reflection to determine the class of the model and therefore I need to read the line containing class information (such as, the first line), and when I've created the object, read() function will do the reset.
Thanks for your reply @yinlou - I've now added Javadoc to the RandomForest.read() method to indicate that the method is intended to be used internally and that PredictorReader.read should be used instead, and I've removed the readLine() addition from RandomForest.read(). In the testing I've done, it seems the fix I added to the RandomForest.write() method for the line break is still needed - do let me know if there are any issues with this.
Thanks,
Michael
Hi @michaellavelle, thanks for adding the comment. I think in stead of adding comments for each predictor, it's better to override the document for Predictor.read() and Predictor.write(). You can see the diff in latest version. To prevent confusion in the future, I will sketch out a wiki detailing how to work with this package. Thanks for you contribution!
Thanks @yinlou - I've now updated our fork with your fixes - many thanks for all your work on this project
This PR fixes the following exception, occuring on RandomForest.read()
Exception in thread "main" java.lang.NumberFormatException: For input string: "mltk.predictor.tree.ensemble.rf.RandomForest]" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Integer.parseInt(Integer.java:527) at mltk.predictor.tree.ensemble.rf.RandomForest.read(RandomForest.java:40)