Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Defined Cover #97

Closed
leesteinberg opened this issue Jun 5, 2018 · 3 comments
Closed

User Defined Cover #97

leesteinberg opened this issue Jun 5, 2018 · 3 comments

Comments

@leesteinberg
Copy link

leesteinberg commented Jun 5, 2018

Hi there

I can see that there is a TODO to implement a cover defining API. I was wondering what is the best way of creating a user-defined cover at the moment (if it is possible at all). From what I can tell, we are currently restricted to a (n_bins, overlap_perc) method. Is it possible to define a cover explicity (for one or more dimensions in the lens), using cutoff values or similar (like, setting the maximum and minimum values of the covering space in each dimension)? I ask because in its current implementation I think the [non-]presence of an outlier can skew the covering space quite drastically

Let me know what my options are for the covering space. I would also be interested to know the status of the above TODO. More information as to how the cover class currently works might also be useful if I was going to write my own.

Thanks!

Edit: I've modified the code such that you can pass kmapper.map a CoverBounds variable.
if CoverBounds == None: Normal behavior
However, CoverBounds can also be a (ndim_lens, 2) array, with min, max for every dimension of your lens. If the default behavior is fine for a particular dimension, pass it np.float('inf'), np.float('inf').

For example, if I have a lens in R2 and want to set the maximum and minimum of the second dimension to be 0 and 1, I can pass:
mapper.map(CoverBounds = np.array([[np.float('inf'), np.float('inf')],[0,1]])) and that should have the desired behavior.

Edit 2: Might change it so rather than inf detection, works off None detection in the CoverBounds array.

I think a system designed like this should produce exactly the same cover, independent of input data limits.

Devs - let me hear your thoughts on this - I can clean up and submit a pull request.

@sauln
Copy link
Member

sauln commented Jun 5, 2018

hi @leesteinberg. This sounds like a great new feature to add to the library.

Have you seen the cover class implementation? /kepler-mapper/cover.py?

To define your own cover, you could inherit from Cover and change the define_bins method:

class CoverBounds(Cover):
    def __init__(self, bounds):
          self.bounds = bounds

    def find_bins(self, data):
           # return a set of cover elements according to the new bins.

I would be happy to incorporate a pull request for this!

@leesteinberg
Copy link
Author

leesteinberg commented Jun 6, 2018

Submitted pull request #98 implementing CoverBounds class as discussed.

Edit: @sauln I'll think about how to write a test later today...
Edit 2: Test written + added to pull request (it is a slow day at work...) CoverBounds class required slight modification for python 3.4 compatibility, but works now

sauln pushed a commit that referenced this issue Jul 12, 2018
Incorporate bounds into covering class, satisfying Issue #97. This also incorporates commits from PR #87.
@sauln
Copy link
Member

sauln commented Jul 12, 2018

Thanks for working on this @leesteinberg!

@sauln sauln closed this as completed Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants