Giter Club home page Giter Club logo

pygsp's Introduction

PyGSP: Graph Signal Processing in Python

The PyGSP is a Python package to ease Signal Processing on Graphs. The documentation is available on Read the Docs and development takes place on GitHub. A (mostly unmaintained) Matlab version exists.

doc pypi conda binder
zenodo license pyversions
travis coveralls github

The PyGSP facilitates a wide variety of operations on graphs, like computing their Fourier basis, filtering or interpolating signals, plotting graphs, signals, and filters. Its core is spectral graph theory, and many of the provided operations scale to very large graphs. The package includes a wide range of graphs, from point clouds like the Stanford bunny and the Swiss roll; to networks like the Minnesota road network; to models for generating random graphs like stochastic block models, sensor networks, Erdős–Rényi model, Barabási-Albert model; to simple graphs like the path, the ring, and the grid. Many filter banks are also provided, e.g. various wavelets like the Mexican hat, Meyer, Half Cosine; some low-pass filters like the heat kernel and the exponential window; and Gabor filters. Despite all the pre-defined models, you can easily use a custom graph by defining its adjacency matrix, and a custom filter bank by defining a set of functions in the spectral domain.

While NetworkX and graph-tool are tools to analyze the topology of graphs, the aim of the PyGSP is to analyze graph signals, also known as features or properties (i.e., not the graph itself). Those three tools are complementary and work well together with the provided import / export facility.

The following demonstrates how to instantiate a graph and a filter, the two main objects of the package.

>>> from pygsp import graphs, filters >>> G = graphs.Logo() >>> G.compute_fourier_basis() # Fourier to plot the eigenvalues. >>> # G.estimate_lmax() is otherwise sufficient. >>> g = filters.Heat(G, scale=50) >>> fig, ax = g.plot()

Let's now create a graph signal: a set of three Kronecker deltas for that example. We can now look at one step of heat diffusion by filtering the deltas with the above defined filter. Note how the diffusion follows the local structure!

>>> import numpy as np >>> DELTAS = [20, 30, 1090] >>> s = np.zeros(G.N) >>> s[DELTAS] = 1 >>> s = g.filter(s) >>> fig, ax = G.plot(s, highlight=DELTAS)

You can try it online, look at the tutorials to learn how to use it, or look at the reference guide for an exhaustive documentation of the API. Enjoy!

Installation

The PyGSP is available on PyPI:

$ pip install pygsp

The PyGSP is available on conda-forge:

$ conda install -c conda-forge pygsp

The PyGSP is available in the Arch User Repository:

$ git clone https://aur.archlinux.org/python-pygsp.git
$ cd python-pygsp
$ makepkg -csi

Contributing

See the guidelines for contributing in CONTRIBUTING.rst.

Acknowledgments

The PyGSP was started in 2014 as an academic open-source project for research purpose at the EPFL LTS2 laboratory. This project has been partly funded by the Swiss National Science Foundation under grant 200021_154350 "Towards Signal Processing on Graphs".

It is released under the terms of the BSD 3-Clause license.

If you are using the library for your research, for the sake of reproducibility, please cite the version you used as indexed by Zenodo. Or cite the generic concept as:

@misc{pygsp,
  title = {PyGSP: Graph Signal Processing in Python},
  author = {Defferrard, Micha\"el and Martin, Lionel and Pena, Rodrigo and Perraudin, Nathana\"el},
  doi = {10.5281/zenodo.1003157},
  url = {https://github.com/epfl-lts2/pygsp/},
}

pygsp's People

Contributors

alafaye avatar basilechatillon avatar bricaud avatar cafeal avatar eiffl avatar jbcdnr avatar kalofolb avatar kikohs avatar lionel-martin avatar mdeff avatar nperraud avatar scottgigante avatar the-glu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygsp's Issues

Spectrogram plot

I was trying to plot the spectrogram plot but it doesn't work. There is no errors, but the plot does not show. here is the code I'm using:

import pygsp as pg
import matplotlib.pyplot as plt

G = pg.graphs.Ring(15)
G.estimate_lmax()
G.plot_spectrogram()
pg.plotting.show()

I also tried using plt.show() but no luck. I'm using version 0.5.1 and was trying to follow tutorial .

Bug in graph.compute_fourier_basis

When you call graph.compute_fourier_basis(n_eigenvectors=k), only the first k-1 eigenvectors are computed, because of the design of the function sparse.linalg.eigsh.

In particular, we have as a consequence that graph.set_coordinates(kind='laplacian_eigenmap2D') sets graph.coords to a one-dimensional vector.

New release needed

The release we get with pypi is 0.5.1 and the version on the master branch is also tagged 0.5.1 even if it has many new features. It confuses people, especially when looking at the doc. People mix the 'stable' and 'latest' tag in the doc. I would suggest to make a new release.
I guess it would solve some of the issues opened. I also had students confused during a course on networks and data science where they use it for their project.
Happy new year! :)

maybe a bug about extract_components(self)

Hi,I try to use the extract_components(self) to get the connected components,but it always return the graph which I input. Then I read the source and find the code 'stack = set(np.nonzero(~visited)[0])' that build a stack with all nodes in graph, maybe it should be 'stack = set([np.nonzero(~visited)[0][0]])'? I think the stack should have only one node at the beginning, so that it can split the connected parts. Is that right?
微信截图_20201225175209

optimization doesn't appear to run currently

I've forked pygsp and started implementing the tikhonov optimization on my branch, but it appears that

  1. The current implementation of optimization.prox_tv does not work because
  2. pyunlocbox does not yet support the non-tight frame problem.
    Regardless, I think I've fixed prox_tv up to this error with pyunlocbox. Once I get prox_tik done/documented, i'll switch over to pyunlocbox and see what I can do about the non-tight frame case.

Error when running the sample code in the README file

This sample code in the Readme file

>>> from pygsp import graphs, filters
>>> G = graphs.Logo()
>>> G.compute_fourier_basis()  # Fourier to plot the eigenvalues.
>>> # G.estimate_lmax() is otherwise sufficient.
>>> g = filters.Heat(G, scale=50)
>>> fig, ax = g.plot()

throws the error line 79, in __init__ super(Heat, self).__init__(G, g, **kwargs) TypeError: __init__() got an unexpected keyword argument 'scale'.

The problem seems to be that filters. Heat doesn't have a scale parameter.

In a related note, I noticed that the content in Read the Docs page is not the same as the Readme file (perhaps that's how it should be, I'm not really familiar in how "Read the Docs" is built). In particular, in the read the docs, the example calls the filter function as g = filters.Heat(G, tau=100), which uses the correct parameter.

I'm running PyGSP 0.5.1 (installed using conda).

example not working

I try to compute this example:

G = graphs.Torus()
G.compute_fourier_basis(n_eigenvectors=64)
G.U.shape

but got:

TypeError: compute_fourier_basis() got an unexpected keyword argument 'n_eigenvectors'

Can't run the tutorials

Howdy!

I am trying to run the tutorial as it is on the docs, and I get the following:

from pygsp import graphs, plotting
2
import numpy as np
3

4
G = graphs.Sensor(N=256, seed=42)
5
G.compute_fourier_basis()
6

Create label signal

7
label_signal = np.copysign(np.ones(G.N), G.U[:, 3])
8

1
G.plot_signal(label_signal)
(<Figure size 432x288 with 2 Axes>,
<matplotlib.axes._subplots.AxesSubplot at 0x1e2feb61780>)

1
rs = np.random.RandomState(42)
2

Create the mask

3
M = rs.rand(G.N)
4
M = (M > 0.6).astype(float) # Probability of having no label on a vertex.
5

Applying the mask to the data

6
sigma = 0.1
7
subsampled_noisy_label_signal = M * (label_signal + sigma * rs.standard_normal(G.N))
8
G.plot_signal(subsampled_noisy_label_signal)
(<Figure size 432x288 with 2 Axes>,
<matplotlib.axes._subplots.AxesSubplot at 0x1e2fee9a400>)

1
import pyunlocbox
2

Set the functions in the problem

3
gamma = 3.0
4
d = pyunlocbox.functions.dummy()
5
r = pyunlocbox.functions.norm_l1()
6
f = pyunlocbox.functions.norm_l2(w=M, y=subsampled_noisy_label_signal,
7
lambda_=gamma)
8

Define the solver

9
G.compute_differential_operator()
10
L = G.D.toarray()
11
step = 0.999 / (1 + np.linalg.norm(L))
12
solver = pyunlocbox.solvers.mlfbf(L=L, step=step)
13

Solve the problem

14
x0 = subsampled_noisy_label_signal.copy()
15
prob1 = pyunlocbox.solvers.solve([d, r, f], solver=solver, x0=x0, rtol=0, maxit=1000)
16

17
G.plot_signal(prob1['sol'])

ValueError Traceback (most recent call last)
in
13 # Solve the problem
14 x0 = subsampled_noisy_label_signal.copy()
---> 15 prob1 = pyunlocbox.solvers.solve([d, r, f], solver=solver, x0=x0, rtol=0, maxit=1000)
16
17 G.plot_signal(prob1['sol'])

c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in solve(functions, x0, solver, atol, dtol, rtol, xtol, maxit, verbosity)
248
249 # Solver specific initialization.
--> 250 solver.pre(functions, x0)
251
252 while not crit:

c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in pre(self, functions, x0)
376 self.smooth_funs = []
377 self.non_smooth_funs = []
--> 378 self._pre(functions, self.sol)
379 self.accel.pre(functions, self.sol)
380

c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in _pre(self, functions, x0)
840
841 def _pre(self, functions, x0):
--> 842 super(mlfbf, self)._pre(functions, x0)
843
844 if len(functions) != 3:

c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in _pre(self, functions, x0)
781 # Dual variable.
782 if self.d0 is None:
--> 783 self.dual_sol = self.L(x0)
784 else:
785 self.dual_sol = self.d0

c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in (x)
761 else:
762 # Transform matrix form to operator form.
--> 763 self.L = lambda x: L.dot(x)
764
765 if Lt is None:

ValueError: shapes (256,916) and (256,) not aligned: 916 (dim 1) != 256 (dim 0)

Any suggestions?

Thank you,
Arash

compute_fourier_basis Assertion Error

I'm having trouble getting past assert self._e[-1] <= 2 with a graph when I try to compute its fourier basis, so I'm wondering in why this assertion would fail? Why does the largest eigenvalue have to be <= 2?

kernel_lowpass has arguments when being called in Expwin source code, what value for x is being passed?

Taken from expwin.py in pygsp:

`def kernel_lowpass(x):
return h(0.5 - x/G.lmax + band_max)
def kernel_highpass(x):
return h(0.5 + x/G.lmax - band_min)

    if (band_min is None) and (band_max is None):
        kernel = lambda x: np.ones_like(x)
    elif band_min is None:
        kernel = kernel_lowpass  #Here what value of x is being passed
    elif band_max is None:
        kernel = kernel_highpass  #Here what value of x is being passed
    else:
        kernel = lambda x: kernel_lowpass(x) * kernel_highpass(x)`

This doubt came to my mind when I wanted to use expwin as high pass filter for my graph. Is this a glitch?

Add a parameter in Community graphs

Community graph has a fixed epsilon-NN graph embedded in the construction of the classes.

We should replace 1e-3 by a parametrized value, potentially even depending on Nc and N.

Install latest version with latest functionality

Dear creators of Pygsp,

I would like to install the latest version with all the latest functionality, labeled as 'latest' on the pygsp website. However, I cannot seem to find a way to do so. I found your suggestion on issue 82 where pip install https://github.com/epfl-lts2/pygsp should do the trick, however this returns a lot of errors to me:

pip install https://github.com/epfl-lts2/pygsp
Collecting https://github.com/epfl-lts2/pygsp
  Downloading https://github.com/epfl-lts2/pygsp
     - 174kB 1.9MB/s
  ERROR: Cannot unpack file /private/var/folders/bw/qvtg52mj1pz37rcd5nr8k8qc0000gn/T/pip-unpack-ee5p_yel/pygsp (downloaded from /private/var/folders/bw/qvtg52mj1pz37rcd5nr8k8qc0000gn/T/pip-req-build-s0ije3vi, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of /private/var/folders/bw/qvtg52mj1pz37rcd5nr8k8qc0000gn/T/pip-req-build-s0ije3vi

Do you know how to solve such an error or is there an easier way to install the version with the latest functionality?

Auto calculation of Laplacian Eigenmap throws error

I think this might be my own fault from when I added the truncated eigendecomposition.

import pygsp
G = pygsp.graphs.RandomRegular()
G.set_coordinates(kind='laplacian_eigenmap2D')
G.plot()

throws

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-338-4a8fe3272aa9> in <module>
      2 G = pygsp.graphs.RandomRegular()
      3 G.set_coordinates(kind='laplacian_eigenmap2D')
----> 4 G.plot()

~/.local/lib/python3.7/site-packages/pygsp/graphs/graph.py in plot(self, vertex_color, vertex_size, highlight, edges, edge_color, edge_width, indices, colorbar, limits, ax, title, backend)
    897                            edges=edges, indices=indices, colorbar=colorbar,
    898                            edge_color=edge_color, edge_width=edge_width,
--> 899                            limits=limits, ax=ax, title=title, backend=backend)
    900 
    901     def plot_signal(self, *args, **kwargs):

~/.local/lib/python3.7/site-packages/pygsp/plotting.py in _plot_graph(G, vertex_color, vertex_size, highlight, edges, edge_color, edge_width, indices, colorbar, limits, ax, title, backend)
    382     check_2d_3d = (G.coords.ndim != 2) or (G.coords.shape[1] not in [2, 3])
    383     if G.coords.ndim != 1 and check_2d_3d:
--> 384         raise AttributeError('Coordinates should be in 1D, 2D or 3D space.')
    385     if G.coords.shape[0] != G.N:
    386         raise AttributeError('Graph needs G.N = {} coordinates.'.format(G.N))

AttributeError: Coordinates should be in 1D, 2D or 3D space.

and on inspection, G.coords.shape == (64, 1).

Bugs in filter.py

In evaluate() 'fd' is assigned two times, the first seems useless:

fd = np.zeros(x.size)
fd = self.g[i](x)
return fd

In filterbank_bounds() if 'bounds' is not provided it does:

if not hasattr(self.G, 'lmax'):
    self.logger.info('FILTERBANK_BOUNDS: Has to estimate lmax.')
    self.G.estimate_lmax()  

if not hasattr(self.G, 'e'):
    self.logger.info(
    'FILTERBANK_BOUNDS: Has to compute Fourier basis.')
    self.G.compute_fourier_basis()
     
rng = self.G.e

but compute_fourier_basis() in graph.py already sets 'lmax' when returning, so I think the first if block should be removed.


Hope it helps. Nice toolbox 👍

Compute partial fourier basis (feature suggestion)

pygsp.graphs.Graph.compute_fourier_basis raises a warning on large matrices.

if self.N > 3000:
    self.logger.warning('Computing the full eigendecomposition of a '
                        'large matrix ({0} x {0}) may take some '
'time.'.format(self.N))

Is it worth adding a function which computes the first n eigenvectors via sklearn.utils.extmath.randomized_svd? I'm happy to write the code for it. Alternatively, if you don't want the additional overhead of adding sklearn as a dependency, that function could be copied into PyGSP.

I'm happy to submit a PR if this is something you're interested in adding.

How to keep the signal values of a heat diffusion higher

Hi developers of Pygsp,

After playing around with some heat diffusion code in your package, I was wondering how I could tweak the settings of:

G = graphs.Grid2d(10,10)
G.estimate_lmax()
taus = [0,1,2,3]
print(len(taus))
g = filters.Heat(G, taus)
DELTA = 25
s = np.zeros(G.N)
s[DELTA] = 1
s = g.filter(s, method='chebyshev', order = 10)
G.plot_signal(s[:,1], limits=[0,1])
for i in range(0,len(taus)):
    print(max(s[:,i]))

To not drop so fast in maximum values. Since the maximum value of the heat origin is dropping and reducing from the original delta 1 to [0.62, 0.41, 0.28]. Also, is there a way to create a filter that eventually fades out completely? Such that I can simulate pressure data originating from a source which then completely disappears after N tau values? That would be great for simulating training data for my machine learning model, which works with pressure sensors that can detect events. Hopefully my explanation is clear enough!

Question on importing from segmented numpy array or point cloud cloud

Hi,

I've read the docs but also.looked around and can't seem to work out how to do. So would appreciate any thoughts. I have a large numpy array that is really an array of voxels. The array is dense so there are alot of nodes. I can use another library to reduce the footprint to nonzero values to point clouds x,y,z,feature (segment label/number). I would really like to convert either of these into a network to use in pygsp to understand wave mechanics. Each node would be connected to it's neighbour but I would really like to understand how to encode the edge with the distance between nodes (perhaps collapsing similar nodes and multiply the edge to represent the distance) but have the nodes labelled as the segmentation label. Any thoughts how to proceed? Would appreciate any help.

Errors when plotting the doctest examples

Many doctest examples try to plot passing an 'ax' argument.
However by default pygsp.plotting sets:
BACKEND = 'pyqtgraph'
So I often get:
TypeError: _qtg_plot_signal() got an unexpected keyword argument 'ax'
The problem is that it takes the following arguments:
_qtg_plot_signal(G, signal, show_edges, plot_name, vertex_size, limits)
Making the matplotlib backend explicit in the calls could help improve the docs.
Another solution is to switch backend automatically when an 'ax' parameter is provided.

demo_wavelets bug: Wk.synthesis(S)

Hello!

I have just downloaded the package using pip install, and I have been trying to reproduce the code as shown on the Graphlet tutorial, but I keep encountering the same error when trying to place a Kronecker signal at a specific vertex by running:
Sf = Wk.synthesis(S)

Error:
cheb_coeffs = operator.compute_cheby_coeff(self, m=order, N=order + 1)
AttributeError: 'module' object has no attribute 'compute_cheby_coeff'.

It seems that the code calls the function filter.py, which, at line 221, calls:
cheb_coeffs = operator.compute_cheby_coeff(self, m=order, N=order + 1)
whereas it should probably call:
cheb_coeffs = fast_filtering.compute_cheby_coeff(self, m=order, N=order + 1)
(seems to work after correcting like this at least...)
I was thus wondering if the toolbox had been updated and if something had perhaps changed?
Thanks for your time and help.

C.D.

Details: anaconda/python2.7; Mac OS Sierra 10.12.3

2d plotting with a 3d coordinate set#

I would like to plot only two of a graph's dimensions. Oftentimes this is desirable because working in 3D can be hard to wrap one's head around. This would be something like a keyword argument g.plot(dims=[1,2]) or such.

I poked my head in the plotting code and it appears that the bulk of the logic in the _plt* and _qtg* functions are built atop calls to _get_coords(G) and conditionals on G.coords.shape. This makes it a little bit difficult to just insert a dims parameter. It could be done, but it'd require a refactor. One hacky option is to alter _plot_graph and _plot_signal (and their upstream methods in graphs.py), to have dims=None as a keyword parameter and have

tmp = G.coords 
if dims and len(dims)<G.coords.shape[1]: 
     G.set_coordinates(tmp[:,dims])
## normal plotting (backend call)
G.set_coordinates(tmp)

Note that this doesn't consume any extra memory due to assignment by reference.

Import & export

Goals:

  • Import from and export to standard Python packages for network science. At least networkx and graph-tool. Optionally, NetworKit, igraph, SNAP.
  • Use the above import & export functionality to load & save graphs and signals in standard formats such as:
  • Further leverage the import & export infrastructure. For example, we may want to use networkx's graph generators, or visualization tools.

@cgallay will implement those features. Any feedback or comment from the community is welcome.

need to add nngraphs to requirements list

Hello,

In update_graph_attr(self, *args, **kwargs) you import "from nngraphs import NNGraph" but do not list this in the requirements.txt and the function fails without it.

I believe this comes from torch?

Thanks!
-dave

doc/tutorials/demo.rst typo

demo.rst says:

You can now access the eigenvalues of the fourier basis with G.e and the eigenvectors G.U, they look like sinuses on the graph. Let's plot the second and third eigenvector, as the one is only constant.

But then, since the index starts at 0, it plots the third and the fourth ones:

pygsp.plotting.plt_plot_signal(G, G.U[:, 2], savefig=True, vertex_size=50, plot_name='doc/tutorials/img/logo_second_eigenvector')
pygsp.plotting.plt_plot_signal(G, G.U[:, 3], savefig=True, vertex_size=50, plot_name='doc/tutorials/img/logo_third_eigenvector')

LineGraph not working

Hi,
I'm using pygsp v0.5.1 installed through conda, and when running the LineGraph example

graph = graphs.Sensor(5)
line_graph = graphs.LineGraph(graph)

I get the following error:

AttributeError: module 'pygsp.graphs' has no attribute 'LineGraph'

Also, if i add the k=2 parameter to the graph = graphs.Sensor(5), i get the following:

TypeError: __init__() got an unexpected keyword argument 'k'

Could you maybe explain how to create a high-pass filter?

Hi,

I am not a Signal Processing expert, I am coming from a more Graph Theory background.
I have the code to create a low-pass filter:

def g(x):
    return 1. / (1. + tau * x)

But I cannot find a way (or example) to create a high-pass version. How could I achieve that?

Thank you for making this amazing package, and kind regards,

Stefan

Small bug in utils.py

In distanz():

# Size verification
if rx != ry:
    raise("The sizes of x and y do not fit")

when the condition is met the following error message is returned:

TypeError: exceptions must derive from BaseException

Something like the following should fix it:

# Size verification
if rx != ry:
    raise ValueError("The sizes of x and y do not fit")

graph_sparsify: can we update the node labels also?

Hi,

I am hoping to sparsify my graph which is a sparse matrix, and I also hope to update my node labels for generated sparsified graph.
Is there a way to update the node labels directly, or get the index of nodes that would be kept in sparsified graph?
Any suggestion to revise the code if the function is not provided yet?

Thank you a lot!

request to add networkx io in stable version

Hello,

Thank you very much for the nice library! I was wondering would it be possible to add the networkx io related function (from_networkx/to_networkx) to the stable version of pygsp? Those seem to be quite important/natural functions but right now those can only be used in the development version.

I prefer the stable version because I am currently using a library built upon pygsp stable. If I switch to dev version, some functions of the library won't work.

Tutorial doesn't work

I downloaded the package using pip and I tried "Introduction to the PyGSP" in tutorials.
And I encountered the below error when running the code.

Code:
import numpy as np
from pygsp import graphs, filters, plotting
plotting.BACKEND = 'matplotlib'
G = graphs.Logo()
G.compute_fourier_basis()
print(G.U)
G.plot_signal(G.U[:, 1], vertex_size=50)

Error:
TypeError: pg_plot_signal() got an unexpected keyword argument 'show_plot'

I use:
MacOS Sierra 10.12.6
python 3.6
PyGSP (0.4.1)

classification_tikhonov modifies one of its parameter taken in input

Hi,

The learning.classification_tikhonov function (and its variants) take the labels y as input. The user of the function should not expect this array to be modified. But because of y[M == False] = 0 the array is modified, which is very annoying. Indeed, for validation purposes, it might be useful to store the real labels in y[M == False].

I suggest to either:

  • document this behavior with a warning
  • modify the function such that it starts by copying the data (that shouldn't be too expansive).

compute_fourier_basis Assertion error

I'm having trouble getting pastassert -1e-12 < G1._e[0] < 1e-12 with a graph when I try to compute its fourier basis, so I'm wondering why this assertion would fail? Why does the largest eigenvalue have to be within that range? How to move past this error? I printed the e[0] and it was -6.426935757176126e-12
But why is it termed as erroneous?

Segmentation fault

edit: apologies, just encountered this on another package, don't think your package is to blame - please ignore

gabor example doesn't work

Hi there,

Was trying out the Gabor filter with the example code given in the comments:

G = graphs.Logo()
k = lambda x: x/(1.-x)
g = filters.Gabor(G, k);
2017-07-26 11:24:27,800:INFO: Gabor : has to compute lmax
2017-07-26 11:24:27,812:INFO: Filter Gabor will calculate and set the eigenvalues to normalize the kernel
Traceback (most recent call last):
File "", line 1, in
TypeError: init() should return None, not 'list'

Thanks, great package!
-dave

compute_jackson_cheby_coeff IndexError

compute_jackson_cheby_coeff is indexing with a float. PR coming.

>>> import pygsp
>>> G = pygsp.graphs.Minnesota()
>>> G.estimate_lmax()
>>> pygsp.filters.compute_jackson_cheby_coeff([0, G.lmax/2], [0, G.lmax], 30)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scottgigante/.local/lib/python3.7/site-packages/pygsp/filters/approximations.py", line 209, in compute_jackson_cheby_coeff
    (np.sin(i * np.arccos(filter_bounds[0])) - np.sin(i * np.arccos(filter_bounds[1])))
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Can't run any examples

Description

No example works.

Most of them have an error related to the number of arguments of the plot() function.

Versions

Windows-10-10.0.17763-SP0
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
NumPy 1.16.3
SciPy 1.2.1
Matplotlib 3.0.3
pygsp 0.5.1

Code to Reproduce (and Results)

D:/Documents/GitHub/pygsp/examples> python eigenvalue_concentration.py
Traceback (most recent call last):
  File "eigenvalue_concentration.py", line 20, in <module>
    graph.plot(graph.U[:, 1], ax=ax[0])
TypeError: plot() takes 1 positional argument but 2 were given

D:/Documents/GitHub/pygsp/examples> python filtering.py
Traceback (most recent call last):
  File "filtering.py", line 28, in <module>
    g = pg.filters.Expwin(G, band_max=0.5)
  File "D:/Programs/Miniconda3/lib/site-packages/pygsp/filters/expwin.py", line 56, in __init__
    super(Expwin, self).__init__(G, g, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'band_max'

D:/Documents/GitHub/pygsp/examples> python fourier_basis.py
Traceback (most recent call last):
  File "fourier_basis.py", line 33, in <module>
    plot_eigenvectors(G, axes[0])
  File "fourier_basis.py", line 27, in plot_eigenvectors
    G.plot(G.U[:, i], limits=limits, colorbar=False, vertex_size=50, ax=ax)
TypeError: plot() takes 1 positional argument but 2 were given

D:/Documents/GitHub/pygsp/examples> python fourier_transform.py
Traceback (most recent call last):
  File "fourier_transform.py", line 32, in <module>
    G.plot(x, limits=[-limit, limit], ax=axes[0, i])
TypeError: plot() takes 1 positional argument but 2 were given

D:/Documents/GitHub/pygsp/examples> python heat_diffusion.py
Traceback (most recent call last):
  File "heat_diffusion.py", line 23, in <module>
    x = np.zeros(G.n_vertices)
AttributeError: 'Grid2d' object has no attribute 'n_vertices'

D:/Documents/GitHub/pygsp/examples> python kernel_localization.py
Traceback (most recent call last):
  File "kernel_localization.py", line 28, in <module>
    g.plot(ax=axs[0], title='heat kernel')
  File "D:/Programs/Miniconda3/lib/site-packages/pygsp/filters/filter.py", line 510, in plot
    plotting.plot_filter(self, **kwargs)
  File "D:/Programs/Miniconda3/lib/site-packages/pygsp/plotting.py", line 85, in inner
    plot(obj, *args, **kwargs)
TypeError: plot_filter() got an unexpected keyword argument 'title'

D:/Documents/GitHub/pygsp/examples> python random_walk.py
Traceback (most recent call last):
  File "random_walk.py", line 28, in <module>
    graph.plot(state, ax=ax, title=r'$/delta P^{}$'.format(step))
TypeError: plot() takes 1 positional argument but 2 were given

D:/Documents/GitHub/pygsp/examples> python wave_propagation.py
Traceback (most recent call last):
  File "wave_propagation.py", line 23, in <module>
    x = np.zeros(G.n_vertices)
AttributeError: 'Grid2d' object has no attribute 'n_vertices'

Bug in `interpolate()` when graph has no `mr` attribute

Hi everyone. I just found myself having trouble with the pygsp.reduction.interpolate function, and the reason was in line 173 of the reduction.py file:

K_reg = getattr(G.mr, 'K_reg', kron_reduction(L_reg, keep_inds))
green_kernel = getattr(
            G.mr, 'green_kernel',
            filters.Filter(G, lambda x: 1. / (reg_eps + x)))

The error raised was claiming that G did not have any mr attribute. I assume an if-else could be added to fix it, as I have done to my local cloned version:

if hasattr(G, 'mr'):
    K_reg = getattr(G.mr, 'K_reg', kron_reduction(L_reg, keep_inds))
    green_kernel = getattr(
        G.mr, 'green_kernel',
    filters.Filter(G, lambda x: 1. / (reg_eps + x)))
else:
    K_reg = kron_reduction(L_reg, keep_inds)
    green_kernel = filters.Filter(G, lambda x: 1. / (reg_eps + x))

This solved for me. As I'm not from a computer science background and I'm not very familiar with the creation of test files, I thought of writing the problem here, instead of making a pull request. I hope this is helpful. I open this issue to raise attention to this problem and, if in fact you guys see that a fix is needed, a pull request is created.

Thanks.

Possibility to change node shape when plotting signal?

Hi pygsp team,

I was trying to find a way to change the shape of a node, is that possible? I cannot seem to find the functionality to do so. I did find the way to change vertex size and color, but not the shape of the nodes. I have two types of sensors in my network and I would like to show that clearly in my figures.

Kind regards and thanks in advance!

Stefan

Problem With Interpolate

Howdy!

I am trying to use the reduction interpolate function, and I encounter the following:

    171     
    172     L_reg = G.L + reg_eps * sparse.eye(G.N)
--> 173     K_reg = getattr(G.mr, 'K_reg', kron_reduction(L_reg, keep_inds))
    174     green_kernel = getattr(G.mr, 'green_kernel',
    175                            filters.Filter(G, lambda x: 1. / (reg_eps + x)))

AttributeError: 'Graph' object has no attribute 'mr

The following is how I am using it; my graph is fully connected, and oneSignal and indeces are one full signal on the graph in np array format and the indices in np array format respectively.

pygsp.reduction.interpolate(graph, oneSignal, indeces)

Any suggestions?

Trouble in from_networkx and to_networkx

I am kind of new to Python. I installed the pygsp package in conda. But when I tried to use the to_networkx() function, it always said that the 'Graph' object has no attribute 'to_networkx'. Could someone help me ? Thanks!

Issue in compute_jackson_cheby_coeff

It seems to have to be corrected from
ch[0] = (2/(np.pi))*(np.arccos(filter_bounds[0])-np.arccos(filter_bounds[1]))
to
ch[0] = (1/(np.pi))*(np.arccos(filter_bounds[0])-np.arccos(filter_bounds[1])).

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.