Skip to content

Commit

Permalink
REFACTOR: Make ExportModel compatible with JsonRFAnalyser (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickEdwards7502 committed Sep 20, 2024
1 parent 4506139 commit 07cd144
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/scala/au/csiro/variantspark/api/ExportModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExportModel(rfModel: RandomForestModel, featureSource: FeatureSource) {
val writer = new BufferedWriter(new OutputStreamWriter(outputStream))

try {
writer.write("{\n\"forest\": ")
writer.write("{\n\"params\" : ")
writer.write(writePretty(rfModel.params))
writer.write(",\n\"trees\": [\n")

Expand Down Expand Up @@ -83,12 +83,16 @@ class ExportModel(rfModel: RandomForestModel, featureSource: FeatureSource) {
writer.flush()
}

writer.write("\n]}\n")
writer.write("\n]")
if (rfModel.params.oob == true) {
writer.write(", \n\"oobErrors\" : ")
writer.write(writePretty(rfModel.oobErrors))
}
writer.write("\n}\n")
} finally {
writer.close()
outputStream.close()
println(s"Model saved successfully to: ${jsonFilename}")
}

println(s"Model saved successfully to: ${jsonFilename}")
}
}

0 comments on commit 07cd144

Please sign in to comment.