Git Product home page Git Product logo

Comments (5)

vinferrer avatar vinferrer commented on July 22, 2024

I saw a previous post commenting the problem but nobody answer him:
#57

from bctpy.

vinferrer avatar vinferrer commented on July 22, 2024

I have checked the function, in line 110-111 you have this error message if the adjacency matrix has negative values:

if np.min(W) < -1e-10:
    raise BCTParamError('adjmat must not contain negative weights')

But then for lines 122 to 138 if we select the negative_sym option or the_asym the program should continue:
if B in ('negative_sym', 'negative_asym'):
W0 = W * (W > 0)
s0 = np.sum(W0)
B0 = W0 - gamma * np.outer(np.sum(W0, axis=1), np.sum(W, axis=0)) / s0

    W1 = W * (W < 0)
    s1 = np.sum(W1)
    if s1:
        B1 = (W1 - gamma * np.outer(np.sum(W1, axis=1), np.sum(W1, axis=0))
            / s1)
    else:
        B1 = 0

elif np.min(W) < -1e-10:
    raise BCTParamError("Input connection matrix contains negative "
        'weights but objective function dealing with negative weights '
        'was not selected')

However since you impose first the condition in lines 110-111 the function doesn't execute at all, I think that the condition from line 110-111 should be eliminated, since in lines 122 to 138 this problem is already dealt if the proper objective function isn't chosen.

from bctpy.

CarloNicolini avatar CarloNicolini commented on July 22, 2024

I believe you can happily eliminate the lines:

if np.min(W) < -1e-10:
    raise BCTParamError('adjmat must not contain negative weights')

Moreover you need to fix a bit the code, there are a few errors using 'negative_asym' or 'negative_sym'. The value of modularity is normalized by s twice in this case and the calculation of both B0 and B1 are wrong. I'll open a pull request with the fixed code.

from bctpy.

aestrivex avatar aestrivex commented on July 22, 2024

from bctpy.

aestrivex avatar aestrivex commented on July 22, 2024

Fixed in PR #65

from bctpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.