Skip to content

Commit

Permalink
Fix efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewuathe committed Jun 23, 2015
1 parent 3a12a2d commit 9c329d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/pyspark/mllib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def appendBias(data):
"""
vec = _convert_to_vector(data)
if isinstance(vec, SparseVector):
entries = dict(zip(vec.indices, vec.values))
entries[len(vec)] = 1.0
return SparseVector(len(vec) + 1, entries)
newIndices = np.append(vec.indices, len(vec))
newValues = np.append(vec.values, 1.0)
return SparseVector(len(vec) + 1, newIndices, newValues)
else:
return _convert_to_vector(np.append(vec.toArray(), 1.0))

Expand Down

0 comments on commit 9c329d8

Please sign in to comment.