Pragmatic Data Science | 7, linear combination, implementation

In a linear combination it is easy to create arbitrarily long sequences of pairs of weights (thetas) and input values (x). But first, just a quick recap of how a simple linear combination might look like.

score = theta_1 * x_1 + theta_2 * x_2 + theta_3 * x_3

Since each x value is multiplied with the theta, we can very easily disable the variable by setting the theta to 0. When working with real world data this procedure of setting the theta to 0 to disable it is commonly used in the practical implementation since it allows for a more optimized implementation.

In coming videos we are going to put these x values and thetas in vectors. Instead of having dynamically sized vectors we can then have vectors static in size, where some items in this vectors are set to 0. Knowing the size of the vector beforehand gives some really good benefits since you can use some tools from python, such as sparse vectors and matrices. These implementations of sparse vectors and matrices are much more effective and uses much less RAM (about 10 times as little) than the python lists which are composed of python objects. But in order to use these implementations from the python library numpy we need to set the size of the array before executing the program.