Skip to content

Commit cb1609b

Browse files
MrBagoambauma
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.
1 parent cafe18d commit cb1609b

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
@@ -173,7 +173,7 @@ def __init__(self, weights, intercept, numFeatures, numClasses):
173173
self._dataWithBiasSize = None
174174
self._weightsMatrix = None
175175
else:
176-
self._dataWithBiasSize = self._coeff.size / (self._numClasses - 1)
176+
self._dataWithBiasSize = self._coeff.size // (self._numClasses - 1)
177177
self._weightsMatrix = self._coeff.toArray().reshape(self._numClasses - 1,
178178
self._dataWithBiasSize)
179179

0 commit comments

Comments
 (0)