Why & Where Matrix used in Real Life Data Science and Machine Learning?

Uses of Matrices in Data Science and Machine Learning

In data science and machine learning, we deal with a lot of numbers and datasets ( dataset means Collection of Multiple tables).

Matrices help us to handle large numbers easily and quickly.


Here are the main uses of matrices:


Storing Data

Any dataset you see (Excel table, CSV file, SQL table) is like a matrix.

Rows = records or samples. ( Row 1, 2, 3, etc.. )
Columns = features or variables. ( Column A, B, C etc...)

Column contains Name, Subject, Employee ID, Attendance, Department, Height, Weight - Such Headings. So Columns contain Features.

Row contains the List of Names, like Akash, Ajith etc.. List of Subject like Maths, English etc.. and Height values like 5 feet, 6 feet etc..  So Row Contains Values.

This method of Storing Data is Best for Everything! (Both Humans and Computers)





Image Processing


Digital Images are stored as matrices. Each Matrix Numbers represent Color or density of a Single Pixel of image.

For example, a black and white image is a 2D matrix of pixel values. A color image is 3 matrices (Red, Green, Blue).



Here you can see Image of Panda is made up of thousands of Small Pixels. These Pixels all work together and show us a Single Image.

Each Pixel has a Matrix Value that tell Computer what color to show in that Pixel.


Linear Regression and Algorithms


Machine learning algorithms like Linear Regression, Logistic Regression, SVM, and Neural Networks use matrices for training and predictions.

Linear regression and many machine learning algorithms use matrices because they allow fast and efficient calculations when working with large data.

Converting Inputs and Outputs of Linear Regression into Matrix Form helps Computer to do mathematical calculations quickly using Python NumPy Libraries.

Weights × Inputs = Prediction. This is a core step in most models. Matrix multiplication helps to do it faster using NumPy or other libraries.





Neural Networks


Each layer in a neural network uses matrix operations (dot product, addition, activation). Without matrices, training a neural network is not possible.

In neuron network, each Neuron or Layer receives input data like Name, Subject, Attendance, Behavior etc. in a matric Number format ( 2121, 23, 100, 45) like this.

Then it performs Matrix multiplication to weight the data ( to find the Importance of data)

Then it send to activation room. The activation room decides whether to activate that neuron or not, so it can provide Correct answer as Output.




Consider Each Silver box outside as Neuron or Layer. These layers each contain a Row value. (1243,23,4545,676) something like this.

Now, the data is sent from Layers to Inner silver Cylinders. They do matrix Multiplication and find the Importance or weight of each data.

Last, it is sent to small colorless Main Round Cylinder, Where it decides whether this input data should be considered for giving proper answer or not. 


Transformations


In data science, we transform data (scale, rotate, normalize). These are done using matrix operations.

We transform the data before giving it to Models. We use Scaling, Rotation and Normalization to transform the data for better accuracy and Speed.

We need Scaling Formula, Rotation Matrix for images etc. 

Using Matrix Transformation, Image can be scaled Rotated, Flipped without affecting Image structure.





Speed and Efficiency


Matrix math is faster and easier for computers than normal number-by-number calculations. That’s why big models depend on matrix algebra.


Example:

Normal Math (one-by-one calculation):

Let’s say you want to calculate salary based on hours worked and rate per hour.

For 3 employees:

Employee 1: 8 hours × 100 = 800
Employee 2: 9 hours × 100 = 900
Employee 3: 7 hours × 100 = 700

You are doing multiplication one by one.


Matrix Math (all-at-once calculation):

Now instead of doing 3 calculations separately, we can do it using matrices.

Hours = [8, 9, 7]
Rate = 100

Now you multiply: [ 8 9 7 ] * [100] = [ 800, 900, 700 ]

Computer does all three calculations in one step using matrix multiplication. This is much faster, especially when you have thousands or millions of rows

Comments

Popular posts from this blog

What is Artificial Intelligence? What is Machine Learning? What is Data Science? how they are related to each other?

Linear Algebra - What is it?

What is a Python Library?