@@ -129,8 +129,9 @@ 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- model.save("myModelPath")
133- val sameModel = RandomForestModel.load("myModelPath")
132+ // Save and load model
133+ model.save(sc, "myModelPath")
134+ val sameModel = RandomForestModel.load(sc, "myModelPath")
134135{% endhighlight %}
135136</div >
136137
@@ -193,8 +194,9 @@ Double testErr =
193194System.out.println("Test Error: " + testErr);
194195System.out.println("Learned classification forest model:\n" + model.toDebugString());
195196
196- model.save("myModelPath");
197- RandomForestModel sameModel = RandomForestModel.load("myModelPath");
197+ // Save and load model
198+ model.save(sc.sc(), "myModelPath");
199+ RandomForestModel sameModel = RandomForestModel.load(sc.sc(), "myModelPath");
198200{% endhighlight %}
199201</div >
200202
@@ -276,8 +278,9 @@ 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
279- model.save("myModelPath")
280- val sameModel = RandomForestModel.load("myModelPath")
281+ // Save and load model
282+ model.save(sc, "myModelPath")
283+ val sameModel = RandomForestModel.load(sc, "myModelPath")
281284{% endhighlight %}
282285</div >
283286
@@ -343,8 +346,9 @@ Double testMSE =
343346System.out.println("Test Mean Squared Error: " + testMSE);
344347System.out.println("Learned regression forest model:\n" + model.toDebugString());
345348
346- model.save("myModelPath");
347- RandomForestModel sameModel = RandomForestModel.load("myModelPath");
349+ // Save and load model
350+ model.save(sc.sc(), "myModelPath");
351+ RandomForestModel sameModel = RandomForestModel.load(sc.sc(), "myModelPath");
348352{% endhighlight %}
349353</div >
350354
@@ -504,8 +508,9 @@ 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
507- model.save("myModelPath")
508- val sameModel = GradientBoostedTreesModel.load("myModelPath")
511+ // Save and load model
512+ model.save(sc, "myModelPath")
513+ val sameModel = GradientBoostedTreesModel.load(sc, "myModelPath")
509514{% endhighlight %}
510515</div >
511516
@@ -568,8 +573,9 @@ Double testErr =
568573System.out.println("Test Error: " + testErr);
569574System.out.println("Learned classification GBT model:\n" + model.toDebugString());
570575
571- model.save("myModelPath");
572- GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load("myModelPath");
576+ // Save and load model
577+ model.save(sc.sc(), "myModelPath");
578+ GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load(sc.sc(), "myModelPath");
573579{% endhighlight %}
574580</div >
575581
@@ -647,8 +653,9 @@ 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
650- model.save("myModelPath")
651- val sameModel = GradientBoostedTreesModel.load("myModelPath")
656+ // Save and load model
657+ model.save(sc, "myModelPath")
658+ val sameModel = GradientBoostedTreesModel.load(sc, "myModelPath")
652659{% endhighlight %}
653660</div >
654661
@@ -717,8 +724,9 @@ Double testMSE =
717724System.out.println("Test Mean Squared Error: " + testMSE);
718725System.out.println("Learned regression GBT model:\n" + model.toDebugString());
719726
720- model.save("myModelPath");
721- GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load("myModelPath");
727+ // Save and load model
728+ model.save(sc.sc(), "myModelPath");
729+ GradientBoostedTreesModel sameModel = GradientBoostedTreesModel.load(sc.sc(), "myModelPath");
722730{% endhighlight %}
723731</div >
724732
0 commit comments