Why is Linear Algebra Useful?
Key Takeaways
The video explains the usefulness of linear algebra in data science, covering topics such as vectorizing code, image recognition, and dimensionality reduction, with a focus on machine learning and deep learning applications.
Full Transcript
why is linear algebra actually useful there are very many applications of linear algebra in data science in particular there are several ones of high importance some are easy to grasp others not just yet in this lesson we will explore three of them vectorizing code also known as a ray programming image recognition dimensionality reduction ok let's start from the simplest and probably the most commonly used one vectorized code we can certainly claim that the price of a house depends on its size suppose you know that the exact relationship for some neighborhood is given by the equation price equals ten thousand one hundred and ninety plus two hundred and twenty three times size moreover you know the sizes of five houses 693 656 1060 487 and 1275 square feet what you want to do is plug in each size in the equation and find the price of each house right well for the first one we get ten thousand one hundred and ninety plus two hundred and twenty three times six hundred and ninety-three equals one hundred and sixty four thousand seven hundred and twenty nine then we can find the next one and so on until we find all prices now if we have 100 houses doing that by hand would be quite tedious wouldn't it one way to deal with that problem is by creating a loop you can iterate over the sizes multiplying each of them by 223 and adding 10,000 190 however we are smarter than that aren't we we know some linear algebra already let's explore these two objects five by two matrix and a vector of length two the matrix contains a column of ones and another with the sizes of the houses the vector contains 10,000 190 and 223 the numbers from the equation if we go about multiplying them we will get a vector of length five the first element will be equal to one times ten thousand 190 plus 693 times 223 the second to one times ten thousand 190 plus 656 times 223 and so on by inspecting these expressions we quickly realize that the resulting vector contains all the manual calculations we made earlier to find the prices in machine learning and linear regressions in particular this is exactly how algorithms work we've got an inputs matrix a weights or a coefficients matrix and an output matrix without diving too deep into the mechanics of it here let's note something if we have 10,000 inputs the initial matrix would be 10,000 by 2 right the weights matrix would still be 2 by 1 when we multiply them the resulting output matrix would be 10,000 by 1 this shows us that no matter the number of inputs we will get just as many outputs moreover the equation doesn't change as it only contained the two coefficients 10,000 190 and 223 all right so whenever we are using linear algebra to compute many value simultaneously we call this array programming or vectorizing code it is important to stress that array programming is much much faster there are libraries such as numpy that are optimized for performing this kind of operations which greatly increases the computational efficiency of our code okay what about image recognition in the last few years deep learning and deep neural networks in particular conquered image recognition on the forefront our convolutional neural networks or CN NS in short what is the basic idea you can take a photo feed it to the algorithm and classify it famous examples are the emne Stata set where the task is to classify handwritten digits Sipho are 10 where the task is to classify animals and vehicles and sigh far 100 where you have 100 different classes of images the problem is that we cannot just take a photo and give it to the computer we must design a way to turn that photo into numbers in order to communicate the image to the computer here's where linear algebra comes in each photo has some dimensions right say this photo is 400 by 400 pixels each pixel in a photo is basically a colored square give it enough pixels and a big enough zoom out causes our brain to perceive this as an image rather than a collection of squares let's dig into that here's a simple grayscale photo the grayscale contains 256 shades of grey where zero is totally white and 255 is totally black or vice versa we can actually express this photo as a matrix if the photo is 400 by 400 and that's a 400 by 400 matrix element of that matrix is a number from zero to 255 it shows the intensity of the color gray and that pixel that's how the computer sees a photo but greyscale is boring isn't it what about colored photos well so far we had two dimensions width and height while the number inside corresponding to the intensity of color what if we want more colors well one solution mankind has come up with is the RGB scale where RGB stands for red green and blue the idea is that any color perceivable by the human eye can be decomposed into some combination of red green and blue where the intensity of each color is from 0 to 255 a total of 256 shades in order to represent a colored photo in some linear algebraic form we must take the example from before and add another dimension color so instead of a 400 by 400 matrix we get a 3 by 400 by 400 tensor this tensor contains three 400 by 400 matrices one for each color red green and blue and that's how deep neural networks work with photos great finally dimensionality reduction since we haven't seen eigenvalues and eigenvectors yet there is not much to say here except for developing some intuition imagine we have a data set with three variables visually our data may look like this in order to represent each of those points we have used three values one for each variable x y&z therefore we are dealing with an M by three matrix so the point I corresponds to a vector X I Y I and Zi note that those three variables XY and Z are the three axes of this plane here's where it becomes interesting in some cases we can find a plane very close to the data something like this this plane is two-dimensional so it is defined by two variables say U and V all points lie on this plane but we can approximately say that they do linear algebra provides us with fast and efficient ways to transform our initial matrix from M by three where the three variables are X Y & Z into a new matrix which is M by 2 where the two variables are U and V in this way instead of having three variables we reduce the problem to two variables in fact if you have 50 variables you can reduce them to 40 or 20 or even 10 how does that relate to the real world why does it make sense to do that well imagine a survey where there is a total of 50 questions three of them are the following please rate from one to five one I feel comfortable around people to I easily make friends and three I like going out now these questions may seem different but in the general case they aren't they all measure your level of extraversion so it makes sense to combine them right that's where dimensionality reduction techniques and linear algebra come in very very often we have too many variables that are not so different so we want to reduce the complexity of the problem by reducing the number of variables thanks for watching if you found this video interesting and want to gain an edge in your career make sure to LIKE comment and subscribe and don't forget to check out some of our other videos for another quick win in the data science skills department
Original Description
👉Sign up for Our Complete Data Science Training with 57% OFF: https://bit.ly/3sJATc9
👉 Download Our Free Data Science Career Guide: https://bit.ly/47Eh6d5
Why is linear algebra actually useful? There very many applications of linear algebra. In data science, in particular, there are several ones of high importance. Some are easy to grasp, others not just yet. In this lesson, we will explore 3 of them:
• Vectorized code also known as array programming
• Image recognition
• Dimensionality reduction
Okay. Let’s start from the simplest and probably the most commonly used one – vectorized
code. We can certainly claim that the price of a house depends on its size. Suppose you know
that the exact relationship for some neighborhood is given by the equation:
Price equals 10,190 + 223 times size. Moreover, you know the sizes of 5 houses 693, 656, 1060, 487, and 1275 square feet.
What you want to do is plug-in each size in the equation and find the price of each house,
right?
Well, for the first one we get: 10190 + 223 times 693 equals 164,729. Then we can find the next one, and so on, until we find all prices.
Now, if we have 100 houses, doing that by hand would be quite tedious, wouldn’t it?
One way to deal with that problem is by creating a loop. You can iterate over the sizes, multiplying
each of them by 223, and adding 10,190. However, we are smarter than that, aren’t we? We know some linear algebra already. Let’s explore these two objects:
A 5 by 2 matrix and a vector of length 2. The matrix contains a column of 1s and another – with the sizes of the houses. The vector contains 10,190 and 223 – the numbers from the equation.
If we go about multiplying them, we will get a vector of length 5. The first element will be equal to:
1 times 10,190 plus 693 times 223. The second to:
1 times 10,190 plus 656 times 223. And so on.
► Consider hitting the SUBSCRIBE button if you LIKE the content: https://www.youtube.com/c/365DataScience?sub_confirmation=1
► VISIT our
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from 365 Data Science · 365 Data Science · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Population vs Sample
365 Data Science
Data Science & Statistics: Levels of measurement
365 Data Science
Statistics Tutorials: Mean, median and mode
365 Data Science
Skewness
365 Data Science
What is a distribution?
365 Data Science
The Normal Distribution
365 Data Science
Central limit theorem
365 Data Science
Student's T Distribution
365 Data Science
Type I error vs Type II error
365 Data Science
Hypothesis testing. Null vs alternative
365 Data Science
The linear regression model
365 Data Science
Simple linear regression model. Geometrical representation
365 Data Science
INDEX and MATCH application of the two functions separately and combined [Advanced Excel]
365 Data Science
INDIRECT Excel Function: How it works and when to use it [Advanced Excel]
365 Data Science
VLOOKUP and MATCH another useful functions combination [Advanced Excel]
365 Data Science
VLOOKUP COLUMN and ROW - Handle large data tables with ease [Advanced Excel]
365 Data Science
The ELIF keyword [Python Fundamentals]
365 Data Science
Working with Tuples in Python
365 Data Science
Database Terminology - A Beginners Guide
365 Data Science
Relational Database Essentials
365 Data Science
Database vs Spreadsheet - Advantages and Disadvantages
365 Data Science
Conditional Statements and Loops
365 Data Science
Backpropagation – The Math Behind Optimization
365 Data Science
Monte Carlo: Forecasting Stock Prices Part I
365 Data Science
Monte Carlo: Forecasting Stock Prices Part II
365 Data Science
Monte Carlo: Forecasting Stock Prices Part III
365 Data Science
365 Data Science Online Program
365 Data Science
Data frames - Creating a data frame
365 Data Science
Data Science & Statistics: Slicing a matrix in R
365 Data Science
Data frames in R - Exporting data in R
365 Data Science
Data frames in R - Transforming data PART II
365 Data Science
Data Frames in R - Subsetting a data frame
365 Data Science
Data Science & Statistics: Matrix arithmetic in R
365 Data Science
Data Science & Statistics: Indexing an element from a matrix
365 Data Science
Data Frames in R - Extending a data frame
365 Data Science
Data Science & Statistics: Creating a matrix in R FASTER
365 Data Science
Data Science & Statistics: Creating a Matrix in R
365 Data Science
Data frames - Importing data in R
365 Data Science
Data frames in R - Getting a sense of your data
365 Data Science
Data frames in R - Transforming data PART I
365 Data Science
Data frames in R - Import a CSV in R
365 Data Science
Data Science & Statistics: Matrix operations in R
365 Data Science
Data Science & Statistics: Matrix recycling in R
365 Data Science
Tableau vs Excel: When to use Tableau and when to use Excel
365 Data Science
Download Tableau: Learn how to download Tableau Public
365 Data Science
Connecting data sources: Useful tips when connecting data sources to Tableau
365 Data Science
The Tableau interface: See how to navigate through the Tableau interface
365 Data Science
Tableau data visualization: Create your first Tableau visualization!
365 Data Science
Duplicating sheets: This is how to duplicate a sheet in Tableau
365 Data Science
Build a table in Tableau: The steps needed to create a simple table in Tableau
365 Data Science
Custom fields in Tableau: Using Tableau operators to create custom fields
365 Data Science
Custom fields in Tableau: Add calculations to tables through custom fields
365 Data Science
Totals in Tableau: Learn how to display subtotals and totals in Tableau
365 Data Science
Gross Margin calculation in Tableau
365 Data Science
What is a filter in Tableau: Set up a filter in Tableau to specify the data you want to show
365 Data Science
Joins in Tableau: Inner, outer, left, or a right join in Tableau
365 Data Science
Building a Tableau dashboard: Three types of charts you want to have in a Tableau dashboard
365 Data Science
Creating great looking charts in Tableau: Real life Exercise on charts in Tableau
365 Data Science
Joins in Tableau: Choose the correct join type
365 Data Science
How to make a data check in Tableau: A quick data check is better than no data check
365 Data Science
More on: ML Maths Basics
View skill →
🎓
Tutor Explanation
DeepCamp AI