Repository: spark Updated Branches: refs/heads/master 1816eb3be -> bc66a77bb
[SPARK-20862][MLLIB][PYTHON] Avoid passing float to ndarray.reshape in LogisticRegressionModel ## What changes were proposed in this pull request? Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float. ## How was this patch tested? Existing tests run using python3 and numpy 1.12. Author: Bago Amirbekian <[email protected]> Closes #18081 from MrBago/BF-py3floatbug. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/bc66a77b Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/bc66a77b Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/bc66a77b Branch: refs/heads/master Commit: bc66a77bbe2120cc21bd8da25194efca4cde13c3 Parents: 1816eb3 Author: Bago Amirbekian <[email protected]> Authored: Wed May 24 22:55:38 2017 +0800 Committer: Yanbo Liang <[email protected]> Committed: Wed May 24 22:55:38 2017 +0800 ---------------------------------------------------------------------- python/pyspark/mllib/classification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/bc66a77b/python/pyspark/mllib/classification.py ---------------------------------------------------------------------- diff --git a/python/pyspark/mllib/classification.py b/python/pyspark/mllib/classification.py index 9f53ed0..e04eeb2 100644 --- a/python/pyspark/mllib/classification.py +++ b/python/pyspark/mllib/classification.py @@ -171,7 +171,7 @@ class LogisticRegressionModel(LinearClassificationModel): self._dataWithBiasSize = None self._weightsMatrix = None else: - self._dataWithBiasSize = self._coeff.size / (self._numClasses - 1) + self._dataWithBiasSize = self._coeff.size // (self._numClasses - 1) self._weightsMatrix = self._coeff.toArray().reshape(self._numClasses - 1, self._dataWithBiasSize) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
