Introduction to Linear Algebra
In a typical problem involving data analysis, once we have picked the objective of our analysis, the actual process?often involves?manipulating the numbers present in the dataset. Today, we have advanced computer packages that have bundled together a lot of subtasks, to perform these operations involving
?In this article, we will give you a peek under the hood of the complex machinery used for data science tasks, and closely examine the nuts and bolts that are essential to the smooth functioning of this machinery. Essentially, these nuts and bolts are very simple components that are innovatively used to perform data science tasks.
?
Why Linear Algebra?
This article will take you through the basics of linear algebra. The objective of this learning is to get an intuitive understanding of what is going on behind the scenes when you work on data. Why is this important? We will try answering this question in two parts:
?1. Intuition About Building Blocks
Linear algebra forms a major part of all machine learning. From data preparation to exploratory analysis to final model-building, all the building blocks of machine learning contain linear algebra.
The understanding linear algebra will familiarise you with these building blocks. It will give you some?intuition?of the effects when certain values and parameters in these building blocks are changed.?
?2. Working With Algorithms
When you create a statistical model using a computer,?coefficients or weights of?models are?calculated using linear algebra. Building a model involves the process of?solving a large number of linear equations together. The knowledge of linear algebra will give you a?better understanding of the behavior of algorithms.
?Sometimes, you may even need to?implement algorithms from scratch. You will need to effectively use libraries to perform optimized vector and matrix multiplication. `Besides, the exact notations of linear algebra can directly be used in various environments where you will develop and test your algorithm.
The Foundation of Linear Algebra: Vectors
Let's start our journey into linear algebra with a quick revision of vectors.
?What is a vector?
A vector is a?one-dimensional array?of objects. You can think of it as an ordered list of values. Vectors are used extensively in almost all fields of scientific study. You probably remember vectors from your Physics lessons, where you learned to add and subtract vectors representing quantities such as velocity, acceleration, etc.?in Newtonian Mechanics.?The datasets you will use while performing Machine Learning tasks are generally tabular,?indexed by rows and columns.?Each column of information can be represented as a vector.?
Now, we move on to the defining property of a vector.
?Magnitude And Direction
From your Physics classes, you probably remember vectors as arrows pointing in a certain direction. Vectors are?quantities that possess magnitude and direction. In layman's terms,?magnitude is the "length"?of the vector, and?direction is the "angle".
Unit vectors
Unit vectors are vectors of magnitude 1. While dealing with 2D space, we often use the unit vectors ‘i’ and ‘j’, for vectors pointing in the X and Y directions respectively. For 3D space, the unit vectors are 'i', 'j' and 'k' (for X, Y and Z respectively).
The unit vectors ‘i’ and ‘j’, perpendicular to each other, are also called the basis vectors. These vectors form a?“basis”?of 2D space.?This means we can describe all of 2D space using?these vectors - all the vectors present in the 2D space of Real numbers can be created using linear combinations of these two basis vectors. Any time we describe a vector numerically, there is an implicit choice of a basis for that vector
Vector Operations
Now that you've learnt some basics of vectors, let's proceed with the?different?operations you can perform on vectors. Most of these you may remember from previous studies, and the objective of this section is to revise them and get some intuition for where they may be used during analysing data.
?Vector Addition
When you add two vectors, you can geometrically add them as shown in the figure below. You may remember the following image taught to you?as the "parallelogram rule".
Multiplication with a Scalar
A scalar multiplication, as the name suggests, takes a vector and scales the vector by a numerical factor, keeping the direction exactly the same.
In scaling, magnitude changes by a factor of "c", and direction remains the same.
?