Problem 5.
Consider a dataset with N samples \{ x^{(n)} \in \mathbb{R} \}_{n=0}^{N-1} with N \ge 1000. Let \phi\!\left(x^{(n)}\right) \in \mathbb{R}^d be a feature function of x^{(n)}.
Define the kernel function
\kappa_{ij}= \phi\!\left(x^{(i)}\right)^{\top} \phi\!\left(x^{(j)}\right).
Define the kernel matrix
K = \begin{bmatrix} \kappa_{00} & \kappa_{01} & \cdots & \kappa_{0(N-1)} \\ \kappa_{10} & \kappa_{11} & \cdots & \kappa_{1(N-1)} \\ \vdots & \vdots & \ddots & \vdots \\ \kappa_{(N-1)0} & \kappa_{(N-1)1} & \cdots & \kappa_{(N-1)(N-1)} \end{bmatrix}.
Part 5.1
Suppose
\kappa_{ij}=1 + x^{(i)}x^{(j)} + \left(x^{(i)}x^{(j)}\right)^2.
Compute \phi(x).
(Reasoning is not required.)
Part 5.2
Suppose \kappa_{ij}=\left(1 + x^{(i)}x^{(j)} + 2\left(x^{(i)}x^{(j)}\right)^2\right)^2.
Compute \phi(x).
(Reasoning is not required.)
Part 5.3
Suppose
\kappa_{ij}=\left(1 + x^{(i)}x^{(j)} + 2\left(x^{(i)}x^{(j)}\right)^2\right)^2.
Compute the rank of K.
(Reasoning is required.)
Part 5.4
Let
\Phi =\begin{bmatrix}\phi\!\left(x^{(0)}\right)^{\top} \\ \phi\!\left(x^{(1)}\right)^{\top} \\ \vdots \\ \phi\!\left(x^{(N-1)}\right)^{\top}\end{bmatrix}\in \mathbb{R}^{N \times d}.
Suppose \Phi has the singular value decomposition (SVD)
\Phi = U \Sigma V^{\top}.
Write the trace and the determinant of K in terms of the SVD of \Phi.
(Reasoning is required.)
Part 5.5
This is a coding task.
Copy the following code:
import numpy as np
Write a function in the following way.
The input is \{ x^{(n)} \in \mathbb{R} \}_{n=0}^{N-1} (a one-dimensional NumPy array with shape (N,)).
The return is the kernel matrix K with \kappa_{ij}=\left(1 + x^{(i)}x^{(j)} + 2\left(x^{(i)}x^{(j)}\right)^2\right)^2.
In your code, do NOT use any loop. Do NOT use np.linalg.