How to calculate dot product of two vectors?
DATA MUNGING

How to calculate dot product of two vectors?

How to calculate dot product of two vectors?

This recipe helps you calculate dot product of two vectors

0
This data science python tutorial does the following: 1. Creating customized numpy vectors 2. Taking dot products of two vectors using different methods
In [1]:
## How to calculate dot product of two vectors
def Kickstarter_Example_14():
    print()
    print(format('How to calculate dot product of two vectors','*^72'))

    # Load library
    import numpy as np

    # Create two vectors
    vectorA = np.array([1,2,3])
    vectorB = np.array([4,5,6])

    # Calculate Dot Product (Method 1)
    print(); print(np.dot(vectorA, vectorB))

    # Calculate Dot Product (Method 2)
    print(); print(vectorA @ vectorB)

Kickstarter_Example_14()
**************How to calculate dot product of two vectors***************

32

32
In [2]:
## How to calculate dot product of two matrices
def Kickstarter_Example_14_1():
    print()
    print(format('How to calculate dot product of two matrices','*^72'))

    # Load library
    import numpy as np

    # Create two vectors
    matrixA = np.array([[2, 3, 23],
                       [5, 6, 25],
                       [8, 9, 28]])
    matrixB = np.array([[1, 2, 3],
                       [4, 5, 6],
                       [7, 8, 9]])

    # Calculate Dot Product (Method 1)
    print(); print(np.dot(matrixA, matrixB))

    # Calculate Dot Product (Method 2)
    print(); print(matrixA @ matrixB)

Kickstarter_Example_14_1()
**************How to calculate dot product of two matrices**************

[[175 203 231]
 [204 240 276]
 [240 285 330]]

[[175 203 231]
 [204 240 276]
 [240 285 330]]
In [3]:
## How to describe a matrix
def Kickstarter_Example_14_2():
    print()
    print(format('How to describe a matrix','*^72'))

    # Load library
    import numpy as np

    # Create a matrix
    matrixA = np.array([[2, 3, 23],
                       [5, 6, 25],
                       [8, 9, 28]])

    # View number of rows and columns
    print(); print("Shape: ", matrixA.shape)

    # View number of elements (rows * columns)
    print(); print("Size: ", matrixA.size)

    # View number of dimensions
    print(); print("Dimention: ", matrixA.ndim)

Kickstarter_Example_14_2()
************************How to describe a matrix************************

Shape:  (3, 3)

Size:  9

Dimention:  2

Relevant Projects

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.