Skip to content

Commit

Permalink
[SPARK-15605][ML][EXAMPLES] Fix broken ML JavaDeveloperApiExample.
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?
See [SPARK-15605](https://issues.apache.org/jira/browse/SPARK-15605) for the detail of this bug. This PR fix 2 major bugs in this example:
* The java example class use Param ```maxIter```, it will fail when calling ```Param.shouldOwn```. We need add a public method which return the ```maxIter``` Object. Because ```Params.params``` use java reflection to list all public method whose return type is ```Param```, and invoke them to get all defined param objects in the instance.
* The ```uid``` member defined in Java class will be initialized after Scala traits such as ```HasFeaturesCol```. So when ```HasFeaturesCol``` being constructed, they get ```uid``` with null, which will cause ```Param.shouldOwn``` check fail.

so, here is my changes:
* Add public method:
```public IntParam getMaxIterParam() {return maxIter;}```

* Use Java anonymous class overriding ```uid()``` to defined the ```uid```, and it solve the second problem described above.
* To make the ```getMaxIterParam ``` can be invoked using java reflection, we must make the two class (MyJavaLogisticRegression and MyJavaLogisticRegressionModel) public. so I make them become inner public static class.

## How was this patch tested?
Offline tests.

Author: Yanbo Liang <[email protected]>

Closes apache#13353 from yanboliang/spark-15605.
  • Loading branch information
yanboliang authored and srowen committed Jun 2, 2016
1 parent a0eec8e commit 4fe7c7b
Showing 1 changed file with 0 additions and 240 deletions.

This file was deleted.

0 comments on commit 4fe7c7b

Please sign in to comment.