MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to get the diagonal of a dot product?

# How to get the diagonal of a dot product?

This recipe helps you get the diagonal of a dot product

So this recipe is a short example on how to get the diagonal of dot product. Let's get started.

```
import numpy as np
```

Let's pause and look at these imports. Numpy is generally helpful in data manipulation while working with arrays. It also helps in performing mathematical operation.

```
a = np.random.rand(1000,200)
b = np.random.rand(200,200)
```

We have a defined two random arrays of variable size, one large and one small.

```
print(np.diag(np.dot(a, b)))
print(a)
```

We have used dot function to calculate dot product and thereby diag function to find out the diagonal elements of the dot product.

Once we run the above code snippet, we will see:

Scroll down the ipython notebook to visualize the output.

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.

In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.