Coder Social home page Coder Social logo

Comments (4)

calebgeniesse avatar calebgeniesse commented on May 16, 2024

There is a special undocumented option I added awhile back to help shift the cover bins a bit, so that points near the boundaries were accounted for properly. See scale_limits=True in the following line (executed cell 11 in the notebook):

cover = optimize_cover(
    X, r=15, g=0.67, 
    scale_r=not True, 
    scale_limits=True
)

The corresponding code is defined in dyneusr/mapper/utils.py, see e.g.,

# Define optimized limits
limits = None
if scale_limits is True:
    offset = p_overlap / float(n_cubes)
    limits = [[-offset, 1+offset] for _ in range(ndim)]
    n_cubes += 2 #* ndim

Not 100% sure why this doesn't work with kmapper anymore, but I will take a closer look and see if there's an obvious way to fix this. Otherwise, the easiest thing to do may be to just turn it off in the tutorial, and possibly deprecate the option altogether.

Edit: To clarify, when I use scale_limits=False, I get a graph with 2007 edges and 211 nodes, for the first subject.

from dyneusr.

calebgeniesse avatar calebgeniesse commented on May 16, 2024

For more context, when I use scale_limits=True, I get the following:

>>> cover.limits
array([[-0.04466667,  1.04466667],
       [-0.04466667,  1.04466667]])
>>> cube_centers = cover.fit(lens)
>>> cube_centers
[array([-0.01262745]),
 array([0.05145098]),
 array([0.11552941]),
 array([0.17960784]),
 array([0.24368627]),
 array([0.30776471]),
 array([0.37184314]),
 array([0.43592157]),
 array([0.5]),
 array([0.56407843]),
 array([0.62815686]),
 array([0.69223529]),
 array([0.75631373]),
 array([0.82039216]),
 array([0.88447059]),
 array([0.94854902]),
 array([1.01262745])]
>>> hyper_cubes = cover.transform(lens, cube_centers)
>>> [_.shape for _ in hyper_cubes]
[(3, 2),
 (2, 2),
 (1, 2),
 (1, 2),
 (1, 2),
 (2, 2),
 (2, 2),
 (3, 2),
 (3, 2),
 (4, 2),
 (4, 2),
 (4, 2),
 (3, 2),
 (2, 2),
 (1, 2)]

and when I use scale_limits=False:

>>> cover.limits
None
>>> cube_centers = cover.fit(lens)
>>> cube_centers
[array([-17.97072105]),
 array([-15.59127478]),
 array([-13.2118285]),
 array([-10.83238223]),
 array([-8.45293595]),
 array([-6.07348968]),
 array([-3.6940434]),
 array([-1.31459713]),
 array([1.06484915]),
 array([3.44429542]),
 array([5.82374169]),
 array([8.20318797]),
 array([10.58263424]),
 array([12.96208052]),
 array([15.34152679])]
>>> hyper_cubes = cover.transform(lens, cube_centers)
>>> [_.shape for _ in hyper_cubes]
[(26, 2),
 (40, 2),
 (48, 2),
 (47, 2),
 (47, 2),
 (46, 2),
 (50, 2),
 (58, 2),
 (60, 2),
 (56, 2),
 (49, 2),
 (47, 2),
 (51, 2),
 (50, 2),
 (32, 2)]

So it seems to me like it has to do with the scaling of these limits or the lens itself.

from dyneusr.

calebgeniesse avatar calebgeniesse commented on May 16, 2024

@kristiandroste looping you in here

from dyneusr.

kristiandroste avatar kristiandroste commented on May 16, 2024

Thanks @calebgeniesse!

The notebook runs start to finish without catching any errors when I use scale_limits=False, but it seems something is still not right with my graphs. I document some discrepancies below and will try debugging further

The shapes of my hyper_cubes and my cube_centers differ from those you posted above:
Running

cube_centers = cover.fit(lens)
print(cube_centers)
hyper_cubes = cover.transform(lens, cube_centers)
shapes = [arr.shape for arr in hyper_cubes]
print(shapes)

at the end of cell 12 yields

# cube_centers
[array([-15.88660342]), 
array([-13.70202765]), 
array([-11.51745188]), 
array([-9.33287611]), 
array([-7.14830033]), 
array([-4.96372456]), 
array([-2.77914879]), 
array([-0.59457302]), 
array([1.59000275]), 
array([3.77457852]), 
array([5.95915429]),
array([8.14373006]), 
array([10.32830583]), 
array([12.51288161]), 
array([14.69745738])]

# shapes of hyper_cubes
[(26, 2), 
(41, 2), 
(47, 2), 
(50, 2), 
(54, 2), 
(57, 2), 
(60, 2), 
(61, 2), 
(60, 2), 
(55, 2), 
(45, 2), 
(43, 2), 
(43, 2), 
(43, 2), 
(27, 2)]

Also, the output from cell 11 shows that I'm getting the same shape of X for all subjects:

 X has shape: (242, 577)

Comparing this to the shapes listed in the screenshot of the output in the DyNeuSR Notebooks repo, it appears that this shape is correct for subject 1, but the other five subjects should have different shapes for X.

Visualization of mapper (cell 14), heatmaps (cell 16), and TCM visualizations in step 6 all differ from the output in the DyNeuSR Notebooks repo

from dyneusr.

Related Issues (11)

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.