Skip to content

Commit

Permalink
[SPARK-20862][MLLIB][PYTHON] Avoid passing float to ndarray.reshape i…
Browse files Browse the repository at this point in the history
…n 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 <bago@databricks.com>

Closes #18081 from MrBago/BF-py3floatbug.
  • Loading branch information
MrBago authored and yanboliang committed May 24, 2017
1 parent 1816eb3 commit bc66a77
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyspark/mllib/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def __init__(self, weights, intercept, numFeatures, numClasses):
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)

Expand Down

0 comments on commit bc66a77

Please sign in to comment.