@@ -129,6 +129,7 @@ val testErr = labelAndPreds.filter(r => r._1 != r._2).count.toDouble / testData.
129129println("Test Error = " + testErr)
130130println("Learned classification forest model:\n" + model.toDebugString)
131131
132+ // Save and load model
132133model.save(sc, "myModelPath")
133134val sameModel = RandomForestModel.load(sc, "myModelPath")
134135{% endhighlight %}
@@ -193,6 +194,7 @@ Double testErr =
193194System.out.println("Test Error: " + testErr);
194195System.out.println("Learned classification forest model:\n" + model.toDebugString());
195196
197+ // Save and load model
196198model.save(sc.sc(), "myModelPath");
197199RandomForestModel sameModel = RandomForestModel.load(sc.sc(), "myModelPath");
198200{% endhighlight %}
@@ -276,6 +278,7 @@ val testMSE = labelsAndPredictions.map{ case(v, p) => math.pow((v - p), 2)}.mean
276278println("Test Mean Squared Error = " + testMSE)
277279println("Learned regression forest model:\n" + model.toDebugString)
278280
281+ // Save and load model
279282model.save(sc, "myModelPath")
280283val sameModel = RandomForestModel.load(sc, "myModelPath")
281284{% endhighlight %}
@@ -343,6 +346,7 @@ Double testMSE =
343346System.out.println("Test Mean Squared Error: " + testMSE);
344347System.out.println("Learned regression forest model:\n" + model.toDebugString());
345348
349+ // Save and load model
346350model.save(sc.sc(), "myModelPath");
347351RandomForestModel sameModel = RandomForestModel.load(sc.sc(), "myModelPath");
348352{% endhighlight %}
@@ -504,6 +508,7 @@ val testErr = labelAndPreds.filter(r => r._1 != r._2).count.toDouble / testData.
504508println("Test Error = " + testErr)
505509println("Learned classification GBT model:\n" + model.toDebugString)
506510
511+ // Save and load model
507512model.save(sc, "myModelPath")
508513val sameModel = GradientBoostedTreesModel.load(sc, "myModelPath")
509514{% endhighlight %}
@@ -568,6 +573,7 @@ Double testErr =
568573System.out.println("Test Error: " + testErr);
569574System.out.println("Learned classification GBT model:\n" + model.toDebugString());
570575
576+ // Save and load model
571577model.save(sc.sc(), "myModelPath");
572578GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load(sc.sc(), "myModelPath");
573579{% endhighlight %}
@@ -647,6 +653,7 @@ val testMSE = labelsAndPredictions.map{ case(v, p) => math.pow((v - p), 2)}.mean
647653println("Test Mean Squared Error = " + testMSE)
648654println("Learned regression GBT model:\n" + model.toDebugString)
649655
656+ // Save and load model
650657model.save(sc, "myModelPath")
651658val sameModel = GradientBoostedTreesModel.load(sc, "myModelPath")
652659{% endhighlight %}
@@ -717,6 +724,7 @@ Double testMSE =
717724System.out.println("Test Mean Squared Error: " + testMSE);
718725System.out.println("Learned regression GBT model:\n" + model.toDebugString());
719726
727+ // Save and load model
720728model.save(sc.sc(), "myModelPath");
721729GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load(sc.sc(), "myModelPath");
722730{% endhighlight %}
0 commit comments