Skip to content

Commit d63b5cc

Browse files
committed
fix examples
1 parent 29b004c commit d63b5cc

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public Vector predictRaw(Vector features) {
211211
public MyJavaLogisticRegressionModel copy() {
212212
MyJavaLogisticRegressionModel m =
213213
new MyJavaLogisticRegressionModel(parent_, fittingParamMap_, weights_);
214-
Params$.MODULE$.inheritValues(this.paramMap(), this, m);
214+
Params$.MODULE$.inheritValues(this.extractParamMap(), this, m);
215215
return m;
216216
}
217217
}

examples/src/main/scala/org/apache/spark/examples/ml/DeveloperApiExample.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ private class MyLogisticRegressionModel(
174174
* Create a copy of the model.
175175
* The copy is shallow, except for the embedded paramMap, which gets a deep copy.
176176
*
177-
* This is used for the defaul implementation of [[transform()]].
177+
* This is used for the default implementation of [[transform()]].
178178
*/
179179
override protected def copy(): MyLogisticRegressionModel = {
180180
val m = new MyLogisticRegressionModel(parent, fittingParamMap, weights)
181-
Params.inheritValues(this.paramMap, this, m)
181+
Params.inheritValues(extractParamMap(), this, m)
182182
m
183183
}
184184
}

mllib/src/main/scala/org/apache/spark/ml/param/params.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,17 @@ trait Params extends Identifiable with Serializable {
249249
* extra values from input into a flat param map, where the latter value is used if there exist
250250
* conflicts.
251251
*/
252-
protected final def extractParamMap(extraParamMap: ParamMap = ParamMap.empty): ParamMap = {
252+
protected final def extractParamMap(extraParamMap: ParamMap): ParamMap = {
253253
defaultParamMap ++ paramMap ++ extraParamMap
254254
}
255255

256+
/**
257+
* [[extractParamMap]] with no extra values.
258+
*/
259+
protected final def extractParamMap(): ParamMap = {
260+
extractParamMap(ParamMap.empty)
261+
}
262+
256263
/** Internal param map for user-supplied values. */
257264
private val paramMap: ParamMap = ParamMap.empty
258265

0 commit comments

Comments
 (0)