numpy.identity (n, dtype = None): return the identity matrix, that is, the square matrix with ones on the main daignol.
n: [int] Dimension nxn of output array dtype: [optional, float (by Default)] Data type of returned array.
identity array of dimension nxn, with its main diagonal set to one, and all other elements 0.
Matrix b: [[1. 0.] [0. 1.]] Matrix a: [[1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.]]
These codes will not work for online IDs. Please run them on your systems to see how they work.
This article is courtesy of Mohit Gupta_OMG