Why Linear Algebra for Machine Learning?

Machine learning and deep learning models depend on data. Their performance is highly dependent on the amount of data. So, we tend to collect as much data as possible to build a robust and accurate model. Data is collected in various formats, like numbers, images, text, sound waves, etc. However, we need to convert the data to numbers to analyze and model it.

Also, Read – Machine Learning in Business Problems.

It is not enough to convert the data to scalars (unique numbers). As the number of data increases, operations performed with scalars begin to be inefficient. We need to be vectorized or matrix operations to perform calculations efficiently. This is where linear algebra comes in.

Numpy for Linear Algebra for Machine Learning

Linear algebra is used for matrix multiplication, decompositions, determinants, and other square mathematical computations. In python Unlike some languages ​​like MATLAB, multiplying two two-dimensional arrays with * is an element-by-element product instead of a matrix dot product. As such, there is a function point, both an array method and a function in the NumPy namespace, for matrix multiplication:

import numpy as np
x = np.array([[1., 2., 3.], [4., 5., 6.]])
y = np.array([[6., 23.], [-1, 7], [8, 9]])
print("X: ",x)
print("Y: ",y)
X:  [[1\. 2\. 3.]
 [4\. 5\. 6.]]
Y:  [[ 6\. 23.]
 [-1\.  7.]
 [ 8\.  9.]]

A matrix product between a 2D array and a 1D array of appropriate size results in a 1D array:

 x.dot(y) ## equivalently np.dot(x, y)
array([[ 28.,  64.],
       [ 67., 181.]])
 np.dot(x, np.ones(3))
array([ 6., 15.])

#machine learning #data science #python

Linear Algebra for Machine Learning | Data Science | Machine Learning
1.30 GEEK