Github user MechCoder commented on the pull request:
https://github.com/apache/spark/pull/5946#issuecomment-104125371
@jkbradley I tested it with a number of situations using this script, but
surprisingly there is no improvement by replacing the number of indices and
values.
from pyspark.mllib.linalg import SparseVector
import numpy as np
from time import time
rng = np.random.RandomState(0)
ind1 = np.sort(rng.choice(5000000, 500000, replace=False))
ind2 = np.sort(rng.choice(5000000, 5000, replace=False))
val1 = rng.rand(500000)
val2 = rng.rand(5000)
v = SparseVector(5000000, ind1, val1)
v1 = SparseVector(5000000, ind2, val2)
t = time()
t_ = 0.0
for i in xrange(10):
t = time()
tmp = v.dot(v1)
t_ += time() - t
print t_
t_ = 0.0
for i in xrange(10):
t = time()
tmp = v.dot1(v1)
t_ += time() - t
print t_
t_ = 0.0
for i in xrange(10):
t = time()
tmp = v.squared_distance(v1)
t_ += time() - t
print t_
t_ = 0.0
for i in xrange(10):
t = time()
tmp = v.squared_distance1(v1)
t_ += time() - t
print t_
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]