
Quick Contact
Python Tutorial
- What is Python?
- How to Install Python?
- Python Variables and Operators
- Python Loops
- Python Functions
- Python Files
- Python Errors and Exceptions
- Python Packages
- Python Classes and Objects
- Python Strings
- PostgreSQL Data Types
- Python Generators and Decorators
- Python Dictionary
- Python Date and Time
- Python List and Tuples
- Python Multithreading and Synchronization
- Python Modules
- What is Python bytecode?
- Python Regular Expressions
Python Panda Tutorial
- Python Pandas Tutorial
- Python Pandas Features
- Advantages and Disadvantages of Python Pandas
- Pandas Library In Python
- Pandas Series To Frame
- Python Dataframeaggregate and Assign
- Pandas Dataframe Describe
- Pandas Dataframe Mean
- Pandas Hist
- Pandas Dataframe Sum
- How to convert Pandas DataFrame to Numpy array
- Pandas Concatenation
- Pandas Shift
- Pandas Rolling
- Data Analysis With Pandas and Python
- How Python Panda Are Helpful For With Data Science
Python Selenium
- Selenium Basics
- Selenium with Python Introduction and Installation
- Navigating links using get method Selenium Python
- Locating Single Elements in Selenium Python
- Locating Multiple elements in Selenium Python
Python Flask Tutorial
Python Django
- How to Install Django and Set Up a Virtual Environment in 6 Steps
- Django MTV Architecture
- Django Models
- Django Views
- Django Templates
- Django Template Language
- Django Project Layout
- Django Admin Interface
- Django Database
- Django URLs and URLConf
- Django Redirects
- Django Cookies and Cookies Handling
- Django Caching
- Types of Caching in Django
- Django Sessions
- Django Forms Handling & Validation
- Django Exceptions & Error-handling
- Django Forms Validation
- Django Redirects
- Django Admin Interface
- Django Bootstrap
- Ajax in Django
- Django Migrations and Database Connectivity
- Django Web Hosting and IDE
- Django Admin Customization
- What is CRUD?
- Django ORM
- Django Request-Response Cycle
- Django ORM
- Making a basic_api with DRF
- Django Logging
- Django Applications
- Difference between Flask vs Django
- Difference between Django vs PHP
Numpy
- Numpy Introduction
- NumPy– Environment Setup
- NumPy - Data Types
- NumPy–Functions
- NumPy Histogram
- numPy.where
- numpy.sort
- NumPyfloor
- Matrix in NumPy
- NumPy Arrays
- NumPy Array Functions
- Matrix Multiplication in NumPy
- NumPy Matrix Transpose
- NumPy Array Append
- NumPy empty array
- NumPy Linear Algebra
- numpy.diff()
- numpy.unique()
- numpy.dot()
- numpy.mean()
- Numpy.argsort()
- numpy.pad()
- NumPyvstack
- NumPy sum
- NumPy Normal Distribution
- NumPylogspace()
- NumPy correlation
- Why we learn and use Numpy?
Tensorflow
- Introduction To Tensorflow
- INTRODUCTION TO DEEP LEARNING
- EXPLAIN NEURAL NETWORK?
- CONVOLUTIONAL AND RECURRENT NEURAL NETWORK
- INTRODUCTION TO TENSORFLOW
- INSTALLATION OF TENSORFLOW
- TENSORBOARD VISUALIZATION
- Linear regression in tensorflow
- Word Embedding
- Difference between CNN And RNN
- Explain Keras
- Program elements in tensorflow
- Recurrent Neural Network
- Tensorflow Object Detection
- EXPLAIN MULTILAYER PERCEPTRON
- GRADIENT DESCENT OPTIMIZATION
Interview Questions & Answers
NumPy Linear Algebra
Linear algebra is central to almost all areas of mathematics and computer science. The data is represented by linear equations such as (a1x1 +……+anxn = b), which are presented in the form of matrices and vectors.
Matrix and Vector Products
Here are some of the functions of matrix and vector products which are given below:
Function | Description |
---|---|
dot(a, b) | Computes the dot product of two arrays. |
vdot(a, b) | Computes the dot product of two vectors. |
linalg.multi_dot(a,b,c,d,…) | Computes the dot product of multiple arrays at once. |
inner(a, b) | Computes the inner product of two arrays. |
outer(a, b) | Computes the outer product of two arrays. |
matmul(x1, x2) | Computes the matrix product of two arrays. |
tensordot(a, b,axes) | Computes the tensor dot product of two arrays along the specified axes. |
linalg.matrix_power(a, n) | Raises a square matrix raised to the given power. |
kron(a, b) | Computes the Kronecker product of two arrays. |
einsum(subscripts,*operand) | Evaluates the Einstein summation convention on the operands. |
Example #1
Calculating different type of products of given arrays:
Code:
import numpy as np #creating two arrays a and b a = np.array([2, 1, 2]) b= np.array([4,5,6]) #dot product print("Dot Product of a and b:", np.dot(a,b)) #inner product print("Inner Product of a and b:", np.inner(a,b)) #outer product print("Outer Product of a and b:", np.outer(a,b)) #Kronecker product print("Kronecker Product of a and b:", np.kron(a,b))
Output
Dot Product of a and b: 25 Inner Product of a and b: 25 Outer Product of a and b: [[ 8 10 12] [ 4 5 6] [ 8 10 12]] Kronecker product of a and b: [ 8 10 12 4 5 6 8 10 12]
Let’s see how we calculate all the mentioned products:
Dot product is a.b = ai*bi+aj*bj+ak*bk= [2,1,2].[4,5,6] = 2*4+1*5+2*6 = 25
Inner product is a generalization of dot product. So, it is also calculated similarly to a dot product.
Outer Product of two matrices a and b of sizes (m x 1) and (n x 1) is a resultant matrix (m x n). The product is given by a ⛒ b.
a⛒ b = [2*4 2*5 2*6] [1*4 1*5 1*6][2*4 2*5 2*6] =[ 8 10 12] [ 4 5 6 ] [ 8 10 12]
Kronecker product is the generalization of the outer product. It is also given by a ⛒ b [k0,k1,…,kN] = a[i0,i1,…,iN] * b[j0,j1,…,jN] . The result is given in the form of a block matrix.a⛒ b = [2*4 2*5 2*6] [1*4 1*5 1*6][2*4 2*5 2*6] = [8 10 12] [4 5 6] [8 10 12]
a⛒ b = [2 1 2][4 5 6] = [8 10 12 4 5 6 8 10 12]
Example #2
This is the example of computing the matrix multiplication.
Code:
#creating matrix A and matrix B import numpy as np A = np.array([[1,2,3],[4,5,6],[7,8,9]]) B = np.array([[2,1,3],[4,1,1],[1,2,3]]) #matrix multiplication print("Multiplication of A and B:", np.matmul(A,B)) #raise matrix A to power of 2, i.e, AXA print("Matrix A raised to power of 2:", np.linalg.matrix_power(A,2))
Matrix Eigenvalues
Here are some of the functions of matrix eigenvalues which are given below:
Function | Description |
---|---|
linalg.eig(a) | Computes the eigenvalue of a square matrix. |
linalg.eigvals(a) | Compute the eigenvalues of any matrix. |
linalg.eigh(a) | Computes the eigenvalues and eigenvectors of a complex Hermitian and a real symmetric matrix. |
linalg.eigvalsh(a) | Compute the eigenvalues of a complex Hermitian and real symmetric matrix. |
Example #1
Computing Eigen Values of the given matrix.
Code:
import numpy as np C = np.array([[1,0,0],[0,1,0],[0,0,1]]) print("Array is:",C) #eigen values print("Eigen values of Array is:",np.linalg.eig(C)) print("Eigen values of Array is:",np.linalg.eigvals(C))
Here are some of the functions of matrix and vector products which are given below:
Function | Description |
---|---|
linalg.solve(a, b) | Finds the solution of a linear equation. |
linalg.tensorsolve(a, b) | Finds the solution of a tensor equation. |
linalg.pinv(a) | Computes the pseudo inverse of an array/matrix. |
linalg.tensorinv(a)
linalg.inv(a) |
Computes the inverse of an array/matrix. |
Example #2
Solve two linear equations using the matrix.
Code:
#Equation 1 : 3x+4y = 7 #Equation 2 : 4x+3y = 7 #creating two arrays, one for solution and one for equations import numpy as np A = np.array([[3,4],[4,3]]) B = np.array([7,7]) C = np.linalg.solve(A,B) # solution of equations print("Solution of given linear equations is:",C)
Example #3
This is the example of finding the inverse of a matrix.
Code:
import numpy as np #creating a matrix A A = np.array([[1,1],[0,1]]) #inverse of A print("Inverse of matrix A is :", np.linalg.inv(A))