Skip to content

Linear algebraLesson 4 of 6

Which outputs can the model reach?

Linear combinations and systems of equations

We have made predictions from known weights. Now reverse the question: can any weights reproduce all three observed scores, y=[2,5,8]Ty=[2,5,8]^\mathsf T?

Keep the same input matrix, but leave the weights unknown:

[102131][w1w2]=[258].\begin{bmatrix}1&0\\2&1\\3&1\end{bmatrix} \begin{bmatrix}w_1\\w_2\end{bmatrix} =\begin{bmatrix}2\\5\\8\end{bmatrix}.

The first row requires w1=2w_1=2. The second requires 2w1+w2=52w_1+w_2=5, so w2=1w_2=1. But the third then gives 3(2)+1=73(2)+1=7, not 8. No weight vector satisfies all three equations. This is an inconsistent system, meaning it has no exact solution.

That does not make the records invalid. It tells us that this particular model, with two weights and no intercept, cannot fit these three scores exactly.

Name the columns h=[1,2,3]Th=[1,2,3]^\mathsf T and s=[0,1,1]Ts=[0,1,1]^\mathsf T. The matrix product can also be written

Aw=w1h+w2s.Aw=w_1h+w_2s.

The first weight scales the hours column, the second scales the sets column, and we add the resulting vectors. An expression made by scaling vectors and adding them is a linear combination.

All combinations of these columns form their span, also called the column space of AA. It contains every prediction vector this model can produce. The question “does Aw=yAw=y have a solution?” therefore means “is yy in that column space?”

These column vectors have three coordinates because there are three records. Their coordinates are outputs across records, not hours and sets within one record. A two-feature model can therefore produce a vector with three entries, but it cannot necessarily produce every such vector.

For these columns, every prediction satisfies a useful constraint: its third entry equals its first plus its second. Check it directly:

3w1+w2=w1+(2w1+w2).3w_1+w_2=w_1+(2w_1+w_2).

Our observed scores violate that constraint: 82+58\ne2+5. The target [2,5,7]T[2,5,7]^\mathsf T does satisfy it and has the exact weights [2,1]T[2,1]^\mathsf T.

Can different weights give the same outputs?

Section titled “Can different weights give the same outputs?”

Here the columns are linearly independent: neither is a multiple of the other. More precisely, ah+bs=0ah+bs=0 forces a=0a=0 from the first entry, then b=0b=0 from the second. Their span has dimension 2, so the matrix has rank 2.

Compare a matrix whose columns are hh and 2h2h. Weights [2,0]T[2,0]^\mathsf T and [0,1]T[0,1]^\mathsf T both give 2h2h. Those columns are dependent, and the data cannot distinguish the two contributions. Having two column names does not guarantee two independent directions.

Can our original matrix produce the target [1,4,5]T[1,4,5]^\mathsf T? Find the weights, then check every row.

Work through the answer

The first equation gives w1=1w_1=1. The second gives 2+w2=42+w_2=4, so w2=2w_2=2. The third gives 3+2=53+2=5. Thus w=[1,2]Tw=[1,2]^\mathsf T satisfies all three equations.

Definition

Read the full glossary entry →