How to calculate dot product of two vectors?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

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

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.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

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

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

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.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

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

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

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.