Skip to content

Linear algebraLesson 1 of 6

A record becomes a vector

Vectors, coordinates, and features

Suppose we record study hours, completed practice sets, and a quiz score. These are invented numbers for working through the arithmetic:

RecordHoursSetsScore
1102
2215
3318

The first two measurements are inputs. The score is the output we want to predict. Keeping that distinction matters: putting the score among the inputs would give the model information it will not have when making a new prediction.

Record 2 has input measurements 2 and 1. Put them in a column:

x2=[21].x_2=\begin{bmatrix}2\\1\end{bmatrix}.

This is a vector. Here it represents one record, with hours first and sets second. Swapping the entries changes its meaning. Calling it a vector does not make the measurements more abstract; it gives us a way to calculate with them together.

The subscript in x2x_2 identifies the second record. To name a single entry, use xijx_{ij}: record ii, feature jj. Thus x21=2x_{21}=2 hours and x22=1x_{22}=1 set. Different books choose different conventions, so check the definition before interpreting a subscript.

The notation xiR2x_i\in\mathbb R^2 says that each input has two real-number entries. Read \in as “belongs to” and R2\mathbb R^2 as “the collection of real vectors with two entries.” The superscript describes the number of coordinates; it does not square the measurements.

Subtract records 1 and 2 in matching positions:

x2x1=[2110]=[11].x_2-x_1= \begin{bmatrix}2-1\\1-0\end{bmatrix} =\begin{bmatrix}1\\1\end{bmatrix}.

Record 2 contains one more hour and one more set. Vector subtraction keeps both differences. Multiplying a vector by a single number, called a scalar, scales every entry: 2x2=[4,2]T2x_2=[4,2]^\mathsf T. The superscript T\mathsf T turns a displayed row into a column; the next lessons explain this operation, the transpose.

You can also plot x2x_2 at horizontal coordinate 2 and vertical coordinate 1. The plot and column are two representations of the same ordered pair. With hundreds of features, the arithmetic remains available even though a two-dimensional plot cannot show every coordinate.

Units still matter. Converting hours to minutes changes the first coordinate from 2 to 120. It does not change the underlying record. Raw numerical distance between records therefore depends on how their features are measured.

What is x3x2x_3-x_2, and what does each entry mean?

Work through the answer

[32,11]T=[1,0]T[3-2,1-1]^\mathsf T=[1,0]^\mathsf T: record 3 has one more study hour and the same number of practice sets. This comparison does not establish that the extra hour caused the score difference.

Definition

Read the full glossary entry →