mattburg / EdgeBoost

6 stars 0 forks source link

Possible bug in LinkPrediction #1

Open ronxin opened 9 years ago

ronxin commented 9 years ago

After updating to the scripts in this repo, I still get the error at Line 190 of LinkPrediction.py for a network (not strongly connected).

Error Cannot take a larger sample than population when 'replace=False'
Traceback (most recent call last):
...
  File "../edgeboost/EdgeBoost.py", line 41, in detect_communities
    G = LinkPrediction.link_imputation(G,self.linkPredictor,self.numIterations)
  File "../edgeboost/LinkPrediction.py", line 190, in link_imputation
    linkSample = np.random.choice(linkIndices,numsample,False,scores)
  File "mtrand.pyx", line 1114, in mtrand.RandomState.choice (/private/tmp/easy_install-lylQzH/numpy-1.9.2/numpy/random/mtrand/mtrand.c:10825)
ValueError: Cannot take a larger sample than population when 'replace=False'

In order to temporarily get around it, I added the following line before Line 190 of LinkPrediction.

numsample = min(numsample, linkIndices.size)

I don't know if this will cause any side effects.

mattburg commented 9 years ago

Can you send me the network you are trying to run it on? adding that may be fine, If you have a network where the number of missing edges is not very big then I will need to refactor the code to handle this kind of corner case.

ronxin commented 9 years ago

Attached is the graph that caused the problem.

Xin

On Mon, Apr 20, 2015 at 10:00 PM, mattburg notifications@github.com wrote:

Can you send me the network you are trying to run it on? adding that may be fine, If you have a network where the number of missing edges is not very big then I will need to refactor the code to handle this kind of corner case.

— Reply to this email directly or view it on GitHub https://github.com/mattburg/EdgeBoost/issues/1#issuecomment-94611236.