Skip to content
Snippets Groups Projects
Commit e5fbb182 authored by Zheng RuiFeng's avatar Zheng RuiFeng Committed by Reynold Xin
Browse files

[MINOR] Remove unused arg in als.py

## What changes were proposed in this pull request?
The second arg in method `update()` is never used. So I delete it.

## How was this patch tested?
local run with `./bin/spark-submit examples/src/main/python/als.py`

Author: Zheng RuiFeng <ruifengz@foxmail.com>

Closes #14247 from zhengruifeng/als_refine.
parent 69c77305
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ def rmse(R, ms, us): ...@@ -39,7 +39,7 @@ def rmse(R, ms, us):
return np.sqrt(np.sum(np.power(diff, 2)) / (M * U)) return np.sqrt(np.sum(np.power(diff, 2)) / (M * U))
def update(i, vec, mat, ratings): def update(i, mat, ratings):
uu = mat.shape[0] uu = mat.shape[0]
ff = mat.shape[1] ff = mat.shape[1]
...@@ -88,7 +88,7 @@ if __name__ == "__main__": ...@@ -88,7 +88,7 @@ if __name__ == "__main__":
for i in range(ITERATIONS): for i in range(ITERATIONS):
ms = sc.parallelize(range(M), partitions) \ ms = sc.parallelize(range(M), partitions) \
.map(lambda x: update(x, msb.value[x, :], usb.value, Rb.value)) \ .map(lambda x: update(x, usb.value, Rb.value)) \
.collect() .collect()
# collect() returns a list, so array ends up being # collect() returns a list, so array ends up being
# a 3-d array, we take the first 2 dims for the matrix # a 3-d array, we take the first 2 dims for the matrix
...@@ -96,7 +96,7 @@ if __name__ == "__main__": ...@@ -96,7 +96,7 @@ if __name__ == "__main__":
msb = sc.broadcast(ms) msb = sc.broadcast(ms)
us = sc.parallelize(range(U), partitions) \ us = sc.parallelize(range(U), partitions) \
.map(lambda x: update(x, usb.value[x, :], msb.value, Rb.value.T)) \ .map(lambda x: update(x, msb.value, Rb.value.T)) \
.collect() .collect()
us = matrix(np.array(us)[:, :, 0]) us = matrix(np.array(us)[:, :, 0])
usb = sc.broadcast(us) usb = sc.broadcast(us)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment