Introduction to Linear Algebra.

Source: Deep Learning on Medium

Kindly see the curriculum and topic for each week

In our previous lesson, we did an Introduction to Probability.

Today we will learn LINEAR ALGEBRA.

Don’t worry i will break down the process so you can understand it.


Linear algebra is a branch of mathematics, but the truth of it is that linear algebra is the mathematics of data. Matrices and vectors are the languages of data.

Linear algebra is about linear combinations. That is, using arithmetic on columns of numbers called vectors and arrays of numbers called matrices, to create new columns and arrays of numbers. Linear algebra is the study of lines and planes, vector spaces and mappings that are required for linear transforms.

It is a relatively young field of study, having initially been formalized in the 1800s in order to find unknowns in systems of linear equations. A linear equation is just a series of terms and mathematical operations where some terms are unknown; for example:

y = 4 * x + 1
Equations like this are linear in that they describe a line on a two-dimensional graph. The line comes from plugging in different values into the unknown x to find out what the equation or model does to the value of y.

We can line up a system of equations with the same form with two or more unknowns; for example:

y = 0.1 * x1 + 0.4 * x2
y = 0.3 * x1 + 0.9 * x2
y = 0.2 * x1 + 0.3 * x2

The column of y values can be taken as a column vector of outputs from the equation. The two columns of floating-point values are the data columns, say a1 and a2, and can be taken as a matrix A. The two unknown values x1 and x2 can be taken as the coefficients of the equation and together form a vector of unknowns b to be solved. We can write this compactly using linear algebra notation as:

y = A . b

Problems of this form are generally challenging to solve because there are more unknowns (here we have 2) than there are equations to solve (here we have 3). Further, there is often no single line that can satisfy all of the equations without error. Systems describing problems we are often interested in (such as linear regression) can have an infinite number of solutions.

This gives a small taste of the very core of linear algebra that interests us as machine learning practitioners. Much of the rest of the operations are about making this problem and problems like it easier to understand and solve.

Applications of Linear Algebra

Linear algebra uses equations where y = mx + b to tell where a line can be drawn on a graph. The value of linear equations can be used in buying a cellphone, renting a car, renting a house and many other financial choices.

EX: One cell company A gives you a phone ‘free’ and charges $100 a month for its use and sign a 24 month contract. Another company B makes you buy the phone for $450 but you pay $45 a month. You can quit at any time and the phone is yours. Which is a better deal?

A: ‘b’ is the “Beginning” or upfront cost that you pay before you get the item or service, so the ‘b’ value here = 0. Meanwhile, the ‘m’ or “Moving”cost, because each month you add another payment, so the cost “moves”. In this case for A, the ‘m’ value = $100. ‘y’ = the total cost of the phone over the 24-month period. ‘x’ is for the number of months you use the phone service.

Thus, the equation for A: y = $100x + 0

Using the same idea, Company B: y = $45x + $550

Make each equation equal to one another to find at which month, the cell phone costs the same total amount ‘y’:

$100x + 0 = $45x + $550

-$45x -$45x Subtract $45x from both sides

55x = $550 New equation after subtracting

/$55 /$55 Divide both sides by $55

x = 10 months That means that the first 10 months, Company A costs less because you did not have to pay the “Beginning or Upfront” cost.

BUT, after the 11th-month Company B will cost less for the rest of the 24-month period.

To check, we can put 24 in place of the x-value in each equation to calculate the total cost of your phone and usage.

A: $100 * 24 = $2,400

B: $45 * 24 + $550 = $1,080 + $550 = $1,630

It looks like you paid $770 for your “free” phone.

NOW, you have information to make the best decision for you. You STILL may choose A, because you don’t have the upfront money or the phone normally costs more. But, now you are not making a ‘blind’ decision. You now know that your phone was not really ‘Free’!

House rentals often charge an upfront cleaning fee. Car rentals may charge a ‘guarantee’ fee, so you are less likely to cancel. These are the ‘b’ value in the equation while the $ per mile or $ per day are the ‘m’ value in the linear equations. if I’m not driving far, the per mile is a better deal. If I’m driving a lot, the per day is a better deal. I save money ALL the time…using linear equations.

Numerical Linear Algebra

The application of linear algebra in computers is often called numerical linear algebra.

“numerical” linear algebra is really applied linear algebra.

It is more than just the implementation of linear algebra operations in code libraries; it also includes the careful handling of the problems of applied mathematics, such as working with the limited floating point precision of digital computers.

Computers are good at performing linear algebra calculations, and much of the dependence on Graphical Processing Units (GPUs) by modern machine learning methods such as deep learning is because of their ability to compute linear algebra operations fast.

Efficient implementations of vector and matrix operations were originally implemented in the FORTRAN programming language in the 1970s and 1980s and a lot of code, or code ported from those implementations, underlies much of the linear algebra performed using modern programming languages, such as Python.

Three popular open source numerical linear algebra libraries that implement these functions are:

Linear Algebra Package, or LAPACK.
Basic Linear Algebra Subprograms, or BLAS (a standard for linear algebra libraries).
Automatically Tuned Linear Algebra Software, or ATLAS.

Often, when you are calculating linear algebra operations directly or indirectly via higher-order algorithms, your code is very likely dipping down to use one of these or similar linear algebra libraries. The name of one or more of these underlying libraries may be familiar to you if you have installed or compiled any of Python’s numerical libraries such as SciPy and NumPy.

Linear Algebra and Statistics

Linear algebra is a valuable tool in other branches of mathematics, especially statistics.

Usually, students studying statistics are expected to have seen at least one semester of linear algebra (or applied algebra) at the undergraduate level.

The impact of linear algebra is important to consider, given the foundational relationship both fields have with the field of applied machine learning.

Some clear fingerprints of linear algebra on statistics and statistical methods include:

Use of vector and matrix notation, especially with multivariate statistics.
Solutions to least squares and weighted least squares, such as for linear regression.
Estimates of mean and variance of data matrices.
The covariance matrix that plays a key role in multinomial Gaussian distributions.
Principal component analysis for data reduction that draws many of these elements together.
As you can see, modern statistics and data analysis, at least as far as the interests of a machine learning practitioner are concerned, depend on the understanding and tools of linear algebra.

See more on the application of linear algebra here

See recommended courses

Now you have a clear perception of Linear Algebra, we will come to the conclusion of this lesson, kindly see the recommended articles to explore more.

At the end of this lesson, we have been able to understand:
1. Introduction of Linear Algebra
2. Applications of Linear Algebra
3. Linear Algebra and Statistics.

When you done with this course kindly share your progress on your social media account


Day 9–10: Introduction to Linear Algebra

Day 9–10 Lesson: Today we learned LinearAlgebra and my favorite is the Application of Linear Algebra in our everyday lives.

#100daysofcode #100daysofDscode #100days #Day9–10 #DataScience #MachineLearning #Ai #Probability