question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem With Interpolate

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
codenameAggiecommented, Nov 9, 2019

Howdy!

Thank you sooo much; this is exactly what I needed! I was also using the wrong version of pyGSP, as I was using the 0.5.1, using pip install. I changed to the github version and I have things figured out now.

Thanks again, Arash

1reaction
nperraudcommented, Nov 8, 2019

Hi Arash,

I think what the best for you would be to use some basic interpolator based on a smoothness assumption.

We have function that will just do the trick for you (in master but for the next release). Here is an example.

from pygsp import graphs, learning, filters
import matplotlib.pyplot as plt
import numpy as np

G = graphs.Sensor(seed=42)
G.estimate_lmax()

# Create a ground truth signal:
g = filters.Heat(G, 10)
signal = g.filter(np.random.randn(G.n_vertices))

# Construct a measurement signal from a binary mask:
rs = np.random.RandomState(42)
mask = rs.uniform(0, 1, G.n_vertices) > 0.5
measures = signal.copy()
measures[~mask] = np.nan

# Solve the classification problem by reconstructing the signal:
recovery = learning.regression_tikhonov(
    G, measures, mask, tau=0)

# Plot the results.
# Note that we recover the class with ``np.argmax(recovery, axis=1)``.
fig, ax = plt.subplots(1, 3, sharey=True, figsize=(10, 3))
G.plot_signal(signal, ax=ax[0], title='Ground truth')
G.plot_signal(measures, ax=ax[1], title='Measurements')
G.plot_signal(recovery, ax=ax[2], title='Recovered class')
fig.tight_layout()

taken from https://github.com/epfl-lts2/pygsp/blob/bf4e4374fe925c6d5944b1d6016b812b8f4d3915/pygsp/learning.py#L254

Here is what you should get: image

Good luck

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interpolation Problem - an overview ... - ScienceDirect.com
The basic problem, referred to as the functional scattered data problem is to find a surface that interpolates or approximates a finite set...
Read more >
The interpolation problem - GitHub Pages
In the interpolation problem we are given the values (tk,yk) for k=0,…,n. Let us consider the nodes tk of the problem to be...
Read more >
Interpolation - Wikipedia
In the mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on...
Read more >
Interpolation Problem Statement - Python Numerical Methods
Interpolation Problem Statement¶. Assume we have a data set consisting of independent data values, xi, and dependent data values, yi, where i=1,…,n.
Read more >
Problems with Linear Interpolation - Brown CS
Problems with Linear Interpolation · Lack of realism · Few things in real life move in straight lines · Few motions in real...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found