<p>The solution is in the scipy official doc (<a href="https://docs.scipy.org/doc/scipy/tutorial/interpolate.html#spline-interpolation-in-1-d-procedural-interpolate-splxxx" rel="nofollow noreferrer">link</a>).</p>
<ul>
<li>Use <code>bisplrep</code> function (<em>rep</em> stands for representation) to obtain the interpoltaion output <code>tck</code> (see the docstring for <code>bisplrep</code>).</li>
<li>The output <code>tck</code> is an array and can be stored in a file.</li>
<li>Use <code>bisplev</code> (<em>ev</em> stands for evaluation) to constrcut an function.</li>
</ul>
<p>For using nueral network at interpolation see this state-of-the-art (<a href="https://arxiv.org/abs/1906.05661" rel="nofollow noreferrer">paper</a>)
<em>Training Neural Networks for and by Interpolation</em>.</p>
How to reuse the coefficient obtained from scipy.interpolate.RectBivariateSpline.get_coeffs() to reconstruct the interpolation function?
<p>I have a huge 3D (x,y,z) data set with (x,y) being the inputs and (z) is the output. Now the dataset is very large, and I need to use that information in real time with minimal delay.</p>
<p>Therefore, indexing/look-up table might seem slow. So my thought is to interpolate the dataset and in real time, instead of look-up table, I calcualte the value. So I don't have to store the original dataset but instead I can store the coefficients, which hopefully would be of smaller size than the original data set.</p>
<p>I used the <code>scipy.interpolate.RectBivariateSpline</code> to perform interpolation. And I was able to fit the data and also obtain coefficients. But I am not sure how to reconstruct the interpolation function from the coefficients.</p>
<p>I want to emphesize that the interpolation function will only be evaluated at input (x,y). Generalization is not of concern here.</p>
<pre><code>from scipy import interpolate
import numpy as np

x = np.arange(1,500)
y = np.arange(2,200)

X,Y = np.meshgrid(x,y)
z = np.sin(X+Y).T

a = interpolate.RectBivariateSpline(x,y,z)

# print(len(a.get_coeffs()))
# coefficients can be obtained by a.get_coeffs()
# I want to have the following
# f = construct_spline_from_coefficient(a.get_coeffs())
# z = f(x_old, y_old)

</code></pre>
<p>Another approach I had in mind is use deep neural network. Can anyone shed some light here? Is this an over-kill?</p>