Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Walchand Institute of Technology, Solapur

INFORMATION TECHNOLOGY
COURSE:  MACHINE LEARNING
  CLASS: B.E. [I.T.] -20-21
(SEM-II)
Name: Archana Vivekanand Soma
Roll No: 08
Assignment 2
Problem Statement: To Perform Matrix Operations such as Matrix Addition,
Matrix Subtraction, Matrix Multiplication, and  Rank of matrix.

1)Addition of Matrix:

import numpy as np

matrix_a = np.array([[1, 1, 1],

[1, 1, 1],

[1, 1, 2]])

matrix_b = np.array([[1, 3, 1],

[1, 3, 1],

[1, 3, 8]])

np.add(matrix_a, matrix_b)

1
Walchand Institute of Technology, Solapur
INFORMATION TECHNOLOGY
COURSE:  MACHINE LEARNING
  CLASS: B.E. [I.T.] -20-21
(SEM-II)
Name: Archana Vivekanand Soma
Roll No: 08
Assignment 2

2)Substraction of Matrix:

import numpy as np

matrix_a = np.array([[1, 1, 1],


[1, 1, 1],
[1, 1, 2]])

matrix_b = np.array([[1, 3, 1],


[1, 3, 1],
[1, 3, 8]])

2
Walchand Institute of Technology, Solapur
INFORMATION TECHNOLOGY
COURSE:  MACHINE LEARNING
  CLASS: B.E. [I.T.] -20-21
(SEM-II)
Name: Archana Vivekanand Soma
Roll No: 08
Assignment 2
np.subtract(matrix_a, matrix_b)

3)Multiplication of Matrix:

import numpy as np
matrix_a = np.array([[1, 1],
[1, 2]])
matrix_b = np.array([[1, 3],
[1, 2]])

np.dot(matrix_a, matrix_b)

3
Walchand Institute of Technology, Solapur
INFORMATION TECHNOLOGY
COURSE:  MACHINE LEARNING
  CLASS: B.E. [I.T.] -20-21
(SEM-II)
Name: Archana Vivekanand Soma
Roll No: 08
Assignment 2

4)Rank of Matrix:

import numpy as np
matrix = np.array([[1, 1, 1],
[1, 1, 10],
[1, 1, 15]])

np.linalg.matrix_rank(matrix)

You might also like