# Matrix

Matrix is one of the mathematical models which is very useful while working on data set which we feed machine learning algorithms. Simply, we can call matrix as an array of object in machine learning case (from the mathematical side we can call it as an array of numbers). 2 Rows 3 Columns Matrix

Matrixes are very useful while we are working on machine learning algorithms, assume that we have 1000 data with 10 features for each row, by using matrix structure we can easily handle this data and access any member of it according to requirements, such data can be defined as 1000 rows 10 columns.

We can add two equal matrices (both matrices has to be same sizes of rows and columns).
While adding one matrix to another one, the rule is computing each row of the first matrix to the same row of the second matrix (as position), it is same for columns as well. These are the calculations:
5+6 = 11       4+2 = 6
8+9 = 17       3+5 = 8

## Subtracting

We can subtract two equal matrices from each other (both matrices has to be same sizes of rows and columns). We can define as addition of a negative matrix: Matrix1 + (−Matrix2) These are the calculations:
5-6 = -1       4-2 = 2
8-9 = -1       3-5 = -2

## Multiply

Multiplying has some additional points to pay attention when we want to multiply a matrix with the constant it is pretty simple (called scalar multiplication), but when we want to multiply a matrix by another matrix, we need to use dot product.

## Multiply by Constant

Simply we multiply constant with each row and column of the matrix. These are the calculations:
2x5 = 10       2x4 = 8
2x8 = 16       2x3 = 6

## Multiplying a Matrix by Another Matrix

Here, we need to use dot product to be able to multiply a matrix by another matrix These are the calculations:
(5x1) + (8x3) + (3x2) = 35

Multiplying the first row with all its columns of the first matrix by the first column of the second matrix with the all its rows and sum up all will give us first column of the first row of the result matrix. These are the calculations:
(5x3) + (8x4) + (3x5) = 62

By continuing to do this as multiplying the first row with all its columns of the first matrix by the second column of the second matrix with the all its rows and sum up all will give us the second column of the first row of the result matrix.

With the same logic we can continue to multiply the second row of the first matrix by each column and its all rows of the second matrix, and then sum up will give us the second row of the result matrix with all columns of it. ## Inverse

The inverse of the matrix is the same idea with reciprocal of a Number, the difference is we write it as A-1.
Please note that sometimes it is possible that matrix does not have the inverse.

## Determinant of 2x2 Matrix We can simply say that the determinant of A equals a times d minus b times c.

## Inverse of 2x2 Matrix

As you can see below, swapping the position of a and d and putting negatives in front of b and c and divide everything by the determinant will give use inverse matrix. ## Dividing

Actually, for matrixes, there is no dividing, instead of dividing matrix, we get inverse and multiply by it.

## Negative

Negative of a matrix is pretty simple, we multiply each column of the row by “-” to find rows and columns of the result matrix. These are the calculations:
- x (5) = -5       - x (8) = -8
- x (4) = -4       - x 3 = -3 ## Transposing

We call swapping the rows and columns as  "transpose" a matrix. “T” is the symbol of the “transpose”

# Recommended Articles

## Check out some recommended articles based on the article which you read  ### Distance Formulas

Math

In the Machine Learning literature very often we can see the terms of dista...

### Distance Formulas

In the Machine Learning literature very often we can see the terms of distance computing. Some of the machine learning algorithms built upon this formulas such KNN, clustering etc. Here we are going to briefly see several types of the distance formulas which used by the machine learning algorithms.  ### Machine Learning

Generic

Machine Learning is a type of artificial intelligence that allows software ...

### Machine Learning

Machine Learning is a type of artificial intelligence that allows software to become able to make prediction of output by using various algorithm via learning from the input training data. To sum up, machine learning is the way to make software find out patterns for the solution by using the trained input data. The algorithm which we use to make software smarter are called “Machine Learning Algorithms”.  ### Microsoft ML .NET

Generic

ML .NET is the new framework which is developed by the Microsoft and releas...

### Microsoft ML .NET

ML .NET is the new framework which is developed by the Microsoft and released May 6th,2019 for the .Net ecosystem. It allows developers to create custom ML models using C# or F# without having to leave the .NET ecosystem. It is an open source and cross-platform machine learning framework which is designed as an extensible platform to consume other popular ML frameworks like Tensor-Flow, ONNX, Infer.NET, and more).