Visualizing Models with Known Functional Form

Intro to data space and parameter space.

Background

Suppose we have a model given by

f~(x)=θ~11+exp⁡(θ~2+θ~3t)\begin{align*} \tilde f(x) = \frac{\tilde \theta_{1}}{1 + \exp(\tilde \theta_2 + \tilde \theta_3t)} \end{align*}

In this model tt is the independent variable and the θ\theta's are parameters of the model. We write θ~\tilde \theta to emphasize that these are the true values of θ\theta but are unknown. Instead we fit a model of this form and call it

f^∗(x)=θ1∗1+exp⁡(θ2∗+θ3∗t)\begin{align*} \hat f^*(x) = \frac{\theta_1^*}{1+ \exp(\theta_2^* + \theta_3^* t)} \end{align*}

In this case we write θ∗\theta^* to emphasize that this is the answer we recover from data. If our model is correct, the data generating process is

y=f~(x)+ϵ\begin{align*} y = \tilde f(x) + \epsilon \end{align*}

Where ϵ\epsilon is the disturbance term. For sake of this discussion, we won't discuss ϵ\epsilon but know that we assume E[ϵ∣t]=0E[\epsilon| t] = 0.

Now, since the goal of research is to find the θ~\tilde \theta's we design an experiment where we sample at time tit_i and recover output yiy_i. Suppose we sample at nn distinct times so that our dataset looks like {(t1,y1),…,(tn,yn)}\{(t_1, y_1), \dots, (t_n, y_n)\}.

Now that we've collected data, we're ready to fit the model with the best parameters.

What does it mean to find the "best" parameters? This depends on how we decide to measure loss. The most conventional loss function is to minimize MSE but depending on the context of your problem, there are many other loss functions that can be chosen.

Visualization

Now that we understand the full context of our modeling problem, we can discuss various visualization of the model

Spaghetti Plot

The spaghetti plot is a visualization of the prediction space for the model. Think of the model as f(t;θ1,θ2,θ3)f(t; \theta_1, \theta_2, \theta_3). Fix θ\theta's so that we now have f(t)f(t) and trace out the line that is formed by plotting all pairs (t,f(t))(t,f(t)) as a line.

Now choose different θ\theta's and repeat the process tracing out a second line.

Repeat this process many times. The result will be a "spaghetti plot" because the many lines, where each line represents a different realization of the θ\theta's.

Finally, we can overlay our data point on the graph by plotting the pairs {(t1,y1),…,(tn,yn)}\{(t_1,y_1),\dots,(t_n,y_n)\}. To keep the metaphor going, we could call these data points "meat balls".

The "best" model in this picture would be the line that passes the "closest" to the data points.

Method:

  1. Choose parameters,θ\pmb \theta, of the model.
  2. Plot f(t)f(t) on tt.
  3. Repeat steps (1) and (2) with various θ\theta.
  4. (Optional) plot observed data. {(t1,y1),…,(tn,yn)}\{(t_1,y_1), \dots, (t_n,y_n) \}

Parameter Space

If allow the parameters to be the axis on the graph, and then we calculate the loss over the set {(t1,y1),…,((tn,yn)}\{(t_1, y_1), \dots, ((t_n, y_n)\}. If we only have 22 parameters, then this plot can be represented as a contour plot.

Can we plot data points in this space? No, but from the previous paragraph we see that we embeded the datapoints as loss in our contour graph.

The best model in this visualization is the one that corresponds to the lowest point on the contour graph.

Method:

  1. Fix all but 2 parameters. so that ∑i=1nL(f(θ1,θ2,ti),yi)\sum_{i=1}^n L(f(\theta_1, \theta_2, t_i), y_i).
  2. Assign the x-axis to θ1\theta_1 and the y-axis to θ2\theta_2.
  3. Plot the losses on the space where the value of the loss is represented by the color. This will form contours that are like a mountainous loss landscape.

Data Space

In dataspace, we assign each axis to some f(ti)f(t_i). We quite certainly will always have more than 33 values of tt to choose from but to visualize this space we can only pick 33 values of tt. After we've chosen the three tit_i's we still don't know what f(ti)f(t_i) evaluates to until will pick values for the θ\theta's. In this space, we can actually plot all values of θ\theta. To see this, fix all but on θ\theta and then let the last θ\theta move freely to trace out a curve living in this 3D space.

As we continue to allow the θ\theta's to vary and tracing out all possible values, we end up with a curved surface (a manifold) living within this space. This manifold is called the model monifold because it shows all the space that model can reach in "data space".

Finally, we can plot the realization of the observed data. In this space, the data can be represented by a single point. Remember the three values of tt we picked to evaluate the output of the model at? Call those point ti,tj,tzt_i, t_j, t_z, then the realized data is simply the point at (yi,yj,yz)(y_i, y_j, y_z). If the speghetti plot didn't have a model realization that passed through all the data points, then the point representing the data in this graph will be off the manifold.

In this space, the best model is the point on the model that has the "smallest" vector reaching to the data point.

Method:

  1. Pick 3 values of tt. Call them {t1,t2,t3}\{t_1, t_2, t_3\}
  2. For all values of θ1,…,θp\theta_1, \dots, \theta_p plot the point (f(θ;t1),f(θ;t2),f(θ;t3))\big(f(\pmb \theta;t_1), f(\pmb \theta; t_2), f(\pmb \theta; t_3)\big). All these dots will form a curved surface called the model manifold.
  3. (Optional) plot the point in space representing the data. This is ((t1,y1),(t2,y2),(t3,y3))\big((t_1, y_1),(t_2, y_2),(t_3, y_3)\big). Note that this will be off the manifold unless ϵ1=ϵ2=ϵ3=0\epsilon_1 = \epsilon_2 = \epsilon_3 = 0.