epfl-lts2 / pygsp

Graph Signal Processing in Python
https://pygsp.rtfd.io
BSD 3-Clause "New" or "Revised" License
483 stars 93 forks source link

Add a graph learning module #57

Open nperraud opened 5 years ago

nperraud commented 5 years ago

Add a small module to learn the graph from the signals.

From the user side, he can simply use the class LearnGraph.

nperraud commented 5 years ago

@kalofolb It would be great if you have a look at the code and the doc. Ideally you could make a small tutorial, similarly to https://github.com/epfl-lts2/pygsp/tree/master/doc/tutorials @mdeff The code is based on this branch https://github.com/epfl-lts2/pygsp/tree/naspert-nn_refactor It should be merged after the other one.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.7%) to 88.409% when pulling 27ed937a3eefe6138d20de93360ae2d41d8cd258 on learngraphnew into 49ff67918d7d7b723cfa58d1bee017809627bd6b on master.

mdeff commented 4 years ago

@nperraud, what is the status of this PR? Did @kalofolb check?

Some comments:

nperraud commented 4 years ago

Did not hear from @kalofolb , I should probably do it myself.

mdeff commented 4 years ago

Thanks! Yeah, we can do the tutorial in a separate PR.

My problem with the name is that LearnGraph is too generic. There are many ways to infer a graph from a set of features, like NearestNeighborsGraph. In my opinion, the name should give some information about how it does it, again like NearestNeighborsGraph.

nperraud commented 4 years ago

Here the method is based on smoothness, but I am not sure that this does help for the name. Another way might be that the classe LearnedGraph would take an argument to switch between learning methods. I would not consider a NNGraph as a learned graph.

mdeff commented 4 years ago

Better to keep one class per method (the separation is clear and the parameters would be messy otherwise).

Well, NNGraph also builds a graph from a set of features. The difference is in the assumptions the methods make about the features.

What about something like graphs.LearnFromSmoothSignals? Not sure about learn or infer, nor signals or features or data. (Alternative methods would go as graphs.Learn*.)

BTW, graphs.NNGraph should probably be renamed graphs.NearestNeighbors. Will do in #43.

nperraud commented 4 years ago

I think it should be LearnedFromSmoothSignals following your idea to not put verbs in class. I think we should keep the word Learned. I am OK with it, but it is not great... Shall I rename the file LearnGraph.py to LearnedGraph.py in the spirit that we put all future LearnedGraph there?

mdeff commented 4 years ago

Let's think a bit more about the name. If we'll group them, you can name the module graphs/learned.py.

kalofolias commented 4 years ago

Did not hear from @kalofolb , I should probably do it myself.

Hi guys, I will do the tutorial! Using new account, didn't take check the old one and missed the conversation.

About the name: if we call it "LearnFromSmoothSignals" it doesn't separate between my method and the one of Dong etal. The separation comes from the regularisation of the degrees vector, so there could be a parameter "method" or "model" with choices between "l2_degrees" or "log_degrees" or similar. But as @mdeff said, then we have different sets of parameters... So how do we name mine versus he one of Dong etal? LearnFromSmoothSignalsLog vs LearnFromSmoothSignalsL2?

mdeff commented 4 years ago

Good to hear from you @kalofolias! Thanks for the tutorial.

Do you like LearnedFromSmoothSignals as a name? Any other idea? Are there settings where we'd prefer Dong et al. over this one? If not, we might as well not wonder about the difference. Will it be implemented? If not, we can think about differentiating the methods when it'll be.

kalofolias commented 4 years ago

Yeah, I think it's an ok name... I can't think of a better one myself. The settings where Dong et al performs better are spotty, but I might implement it for completeness and comparison reasons later.

nperraud commented 4 years ago

I have renamed the graph... But the import is a bit dirty in the __init__.py. To make it clean, I would need to make a subfolder I think. @mdeff I think that you wanted to eventually remove the folder for the nngraphs. Let me know what you want me to do. Also, do you want me to make the code more pep8?

kalofolias commented 4 years ago

Hi guys, First tutorial is ready! I need permissions with this account to push. I also made some improvements to the code by @nperraud and fixed a bug (the distances in matrix Z have to be squared!).

nperraud commented 4 years ago

I cannot give you access... @mdeff , does he really need permission? If yes, can you add him?

mdeff commented 4 years ago

Thanks for your patience. @kalofolias, you should have received an invitation. Upon accepting, you should be able to push your changes to this branch. Thanks for the tutorial!

nperraud commented 4 years ago

Just found a small bug. @kalofolias , please pull

nperraud commented 4 years ago

oh actually you found it as well sorry

mdeff commented 4 years ago

Is @kalofolias actively using this? Can we push his improvements and tutorial while we have it in our mind? Thanks :)

mdeff commented 4 years ago

@nperraud: why wasn't this bug caught by the unit tests? Can we add some to avoid further issues?