Skip to content

Commit 83aeac9

Browse files
MrBagoyanboliang
authored andcommitted
[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. (cherry picked from commit bc66a77) Signed-off-by: Yanbo Liang <[email protected]>
1 parent 1d10724 commit 83aeac9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/pyspark/mllib/classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(self, weights, intercept, numFeatures, numClasses):
171171
self._dataWithBiasSize = None
172172
self._weightsMatrix = None
173173
else:
174-
self._dataWithBiasSize = self._coeff.size / (self._numClasses - 1)
174+
self._dataWithBiasSize = self._coeff.size // (self._numClasses - 1)
175175
self._weightsMatrix = self._coeff.toArray().reshape(self._numClasses - 1,
176176
self._dataWithBiasSize)
177177

0 commit comments

Comments
 (0)