Linear Algebra 1: Vectors
How Vectors can be used to hold data for 1 data point, properties of vectors, and how to create vectors in R & Python.
We will be using some of what you learned in the Coding Section. Make sure to pick 1 language and go over it at least once.
Table of Contents:
What is Linear Algebra
Something to watch out for
Vectors
Vectors in Python
Vectors in R
1 - What is Linear Algebra
Linear Algebra is a field of mathematics that focuses primarily on things like matrices, and vectors. We use both of these when we are working with collection of data, thus linear algebra is often known as ‘the language of data’.
Linear algebra is about combinations. In other words, it’s about using arithmetic (linear) processes on a column of numbers (vectors), and then combining several vectors together to create matrices. Similarly, several matrices can be combined together in order to create tensors, which are used in the library called tensorflow. If you are going to be doing a role which involves a heavy usage of machine learning, understanding & learning linear algebra is mandatory & not optional.
2 - Something to watch out for
The difference between a data scientist and a data scientist that actually uses linear algebra is about $50k per year.
In most high paying Data Science (DS) role, you will be expected to work with 1D arrays, 2D matrices, or 3D Tensors. Basically, any real DS role will have you do something with linear algebra. Be extremely careful of DS roles that pay around $60k, and claim that all you need is excel, and that you won’t really use Lin Algebra much. That is nothing more than a simple Data Analyst (DA) being disguised as a DS role.
No idea why companies disguise DA roles as DS roles, but try to ask for the salary early on, and if it’s closer to $60k, just say goodbye, save your time & move on.
3 - Vectors
Scalars
Before we can talk about vectors, let’s talk about Scalars. A scalar is just a simple number. That’s it. Examples of scalars include things like $BTC price, the current temperature outside, the probability of you winning the lottery, etc… A scalar is just a simple number.
Vectors
Vectors is a list of numbers. In other words, a vector is a list of scalars. We can interpret a vector that has 2 scalars as a simple coordinate on a graph. Let’s say we wanted to create a simple vector called v⃗ =(x,y). Where our vector is called v⃗ , and we give it the x coordinate of a point, and the y coordinate of a point. Now let’s say we are looking at an x coordinate of 5, and a y coordinate of 11. Here is what it would look like with the correct linear algebra notation. Here is a simple example of doing the above:
Basic Notation & Interpretation
Generic Form
When we are dealing with linear algebra in the real world, we don’t only work with 2 rows. What typically happens is we work with n rows, where n is just a simple variable (a placeholder), and then we try to solve equations using it. Here is what a vector x would look like, that has n rows in it.
Although this looks confusing, here is what it means. I have a generic vector x. This vector has n rows in it. Each element in this vector belongs to a Real Number. Real numbers are nothing more than the type of numbers we encounter in our normal day to day life, which is basically everything except complex numbers.
Keep reading with a 7-day free trial
Subscribe to Data Science & Machine Learning 101 to keep reading this post and get 7 days of free access to the full post archives.