From the course: Machine Learning Foundations: Linear Algebra

Introduction to vectors

- [Instructor] When we began our journey into the unknown land of linear algebra, we mentioned a few terms, vectors and matrices, without even explaining what they are and why they're important. Let's start from the basics. Learning what vectors are and how they defer from scalars. You've probably learned definitions of a scalar and vector. Basically a scalar is just a number. And we denote a scalar with a lower-case symbol, such as a or b. Examples of scalars are weight, temperature, or blood pressure. And they're represented by numbers, such as 200 pounds, 55 Fahrenheit, or 120 by 80. We can understand what a vector is by simple example. Imagine a moving car. It has a measure called velocity. It has both a quantity and a direction. Such elements are called vectors, as opposed to scalars, for example, the price of the car, which has magnitude only. We denote vectors with lowercase, bolded Roman letters, such as a and b. Some texts use italics or print an arrow on top. By definition a vector is an ordered list of numbers. The two most important characteristics of vectors are dimensionality, the number of elements in a vector, and orientation, whether the vector is in column orientation standing up tall, or row orientation laying flat and wide. Let's see a few examples of vectors. X is a three dimensional column vector. Y is a 2D column vector, and Z is a 3D row vector. If you look at vectors, X and Z, you probably notice they have the same elements in the same order. You could conclude they're the same, but technically they're different because X is column oriented and Z is row oriented. You may think, "Why does it matter?" If you use vectors for storing data, orientation usually doesn't matter. But when performing arithmetic operations it's extremely important, since the wrong orientation leads to unexpected results or even errors. The dimensionality in linear algebra, the number of elements in the vector, is called the length or the shape of the vector in Python. We have a convention in linear algebra that assumes vectors are column oriented. If they're row oriented, then they are written as with t where t indicates the transpose operation which converts a column vector into row vector. If we would like to represent the vector graphically, then it would look like, the red arrow v is the vector, and in our case, a and b are scalars denoting the magnitude of v in horizontal and vertical directions. The algebraic interpretation of a vector is an ordered list of numbers. The geometric interpretation of a vector is a line that has a specific length and direction also called angle. It is computed relative to the positive X-axis. The two points of a vector are called the tail, where the vector starts, and the head that has the arrow tip, where it ends. We can represent vectors in Python using several data types. The simplest way to represent a vector is with a list. For example, vectorAsList. However, as many linear algebra operations don't work on Python list, we create vectors as NumPy arrays called ND arrays. One example would be vectorAsArray. This array is orientationless array meaning it's neither a row nor a column vector. In NumPy, we indicate orientation with brackets. Let's see it in two examples. RowVector, the outer brackets just group all elements together in one object as an additional set of brackets indicates a row. In case of column vector example, columnVector, we see it has only one column and five rows. Now that we have discovered basic characteristics of vectors, we can head on to vector arithmetic and explore operations and vectors.

Contents