Comments (9)
@jakevdp how should the init() geometry function handle the **kwargs for the adjacency, affinity & laplacian methods? e.g
def init(self,
adjacency_method='auto', adjacency_ags = None,
affinity_method='auto', adjacency_ags = None,
laplacian_method='auto', adjacency_ags = None):
or
def init(self,
adjacency_method='auto', affinity_method='auto', laplacian_method='auto',
**kwargs):
Edit: we shouldn't pass a nbhd radius or affinity radius directly either since they will depend on the adjacency and affinity (for example if it's number of neighbors instead of radius).
from megaman.
In a similar vein with respect to the following situation:
- Initialize geometry object, pass data matrix
- call get_adjacency_matrix(distance_method, **kwargs)
- do something else
- call get_adjacency_matrix(distance_method, **kwargs) again
Since kwargs can be of an arbitrary length I don't think it makes sense to store these and then check and see if they are the same so that if someone calls get_adjacency_matrix() twice then it calculates twice -- even if they have the same arguments. We should therefore encourage users to use the attribute geom.adjacency_matrix to get the existing matrix and only call get_adjacency_matrix() only when they want to re-calculate it.
Same with affinity & Laplacian. This simplifies things I think.
from megaman.
My thought would be:
def init(self, adjacency_method='auto', adjacency_kwds=None,
affinity_method='auto', adjacency_kwds=None,
laplacian_method='auto', adjacency_kwds=None):
Regarding the computation of the matrix... how about we change get_adjacency_matrix
to compute_adjacency_matrix
, so that it's more explicit? Then we could use an adjacency_matrix
attribute (or perhaps a property) to access the already-computed value.
from megaman.
I agree. One more quick questions. If I outline it like this:
def __init__(self, adjacency_method = 'auto', adjacency_kwds=None,
affinity_method = 'auto', affinity_kwds=None,
laplacian_method = 'auto', laplacian_kwds=None):
[...]
def compute_adjacency_matrix(self, copy = False, **kwargs):
[...]
self.adjacency_matrix = compute_adjacency_matrix(self.X, self.adjacency_method,
self.adjacency_kwds, **kwargs)
will the self.compute_adjacency_matrix work as intended passing both the adjacency_kwds passed at initialization AND the **kwargs passed to self.compute_adjacency_matrix() itself?
from megaman.
No, I think you have a danger of getting a repeated argument there. I'd do something like this:
kwds = self.adjacency_kwds.copy()
kwds.update(kwargs)
then pass **kwds
to the function.
(in Python 3.5 you could do kwds = {**self.adjacency_kwds, **kwargs}
but we need backward compatibility for the time being
from megaman.
I figured as much. Thanks again Jake! Things are going well and look much cleaner. I should be able to push the pull request tonight.
from megaman.
Awesome! I'm working on the other parts of the refactor, and I think I'll have it done tonight as well. Tomorrow we can work on merging our two sets of changes.
from megaman.
@jakevdp just an FYI the following functions inside test_geometry:
test_laplacian_unknown_normalization
test_laplacian_create_A_sparse
test_equal_original
are testing affinity/laplacian methods.
from megaman.
re-factor done.
from megaman.
Related Issues (20)
- No operator available that can perform this conversion
- Modified LLE? HOT 8
- Initialization for k_means_clustering
- Any easy way to apply learned mapping on different set of points? HOT 2
- perfomance improvements for ltsa HOT 1
- Cyflann - ValueError: Buffer dtype mismatch, expected 'double' but got 'float' HOT 3
- Megaman benchmarks HOT 6
- errors when running "make test" HOT 2
- cannot import megaman.geometry HOT 2
- errors in OSX and Ubuntu, when `from megaman.embedding import SpectralEmbedding` HOT 1
- errors in OSX and Ubuntu when `from megaman.geometry import Geometry` HOT 2
- different results with the same input HOT 2
- how to choose parameters for megaman HOT 1
- Example for performing Riemannian relaxation? HOT 3
- Manifold dimension in rmetric computation
- can it be used on Windows? HOT 1
- Conda package: broken or missing pyflann dependency HOT 1
- flann/flann.hpp: No such file or directory HOT 3
- When the manifold dim is lower than embedding dim
- Make test failed with ERROR: Failure: ImportError (No module named _check_build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from megaman.