I need to plot this surface. It turns out it was plotted in Matlab. I don’t have access to Matlab so I did the whole thing in python and got the x, y and z for the surface.
This is how it looks:
Is there any chance that this could be made with tikZ?
These are the coordinates:
learning rate:
[0.0,
0.0,
0.0,
0.0,
0.005,
0.005,
0.005,
0.005,
0.01,
0.01,
0.01,
0.01,
0.015,
0.015,
0.015,
0.015]
rmse:
[2.7689,
2.7687,
2.7688,
2.7688,
0.9809,
0.9417,
0.9268,
0.9231,
0.9486,
0.9243,
0.9306,
0.9316,
0.9406,
0.934,
0.9381,
0.9419]
number of epochs:
[10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40]
Algorithm:
Implementation of the algorithm:
def SGD(data):
'''Learn the vectors p_u and q_i with SGD.
data is a dataset containing all ratings + some useful info (e.g. number
of items/users).
'''
n_factors = 10 # number of factors
alpha = .01 # learning rate
n_epochs = 10 # number of iteration of the SGD procedure
# Randomly initialize the user and item factors.
p = np.random.normal(0, .1, (data.n_users, n_factors))
q = np.random.normal(0, .1, (data.n_items, n_factors))
# Optimization procedure
for _ in range(n_epochs):
for u, i, r_ui in data.all_ratings():
err = r_ui - np.dot(p[u], q[i])
# Update vectors p_u and q_i
p[u] += alpha * err * q[i]
q[i] += alpha * err * p[u]
def estimate(u, i):
'''Estimate rating of user u for item i.'''
return np.dot(p[u], q[i])
mwe
\ documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.3}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\begin{axis}
\addplot3[patch,patch refines=3,shader=faceted interp,patch type=biquadratic]
table[z expr=x^2-y^2]
{
x y
-2 -2
2 -2
2 2
-2 2
0 -2
2 0
0 2
-2 0
0 0
};
\end{axis}
\end{tikzpicture}
\end{document}
sagetex
package which gives you a computer algebra system, called SAGE, as well as Python. I've done various examples with 2d such as here or here. A 3D using matplotlib is here. What is the function to generate the coordinates?