DATA MUNGING
DATA CLEANING PYTHON
MACHINE LEARNING RECIPES
PANDAS CHEATSHEET
ALL TAGS
# How to calculate Diagonal of a Matrix?

# How to calculate Diagonal of a Matrix?

This recipe helps you calculate Diagonal of a Matrix

Have to tried to calculate diagonal elements and sum of diagonal values.

So this is the recipe on how we can calculate Diagonal of a Matrix.

```
import numpy as np
```

We have only imported numpy which is needed.

We have created a matrix on which we will perform the operation.
```
matrix = np.array([[1, 2, 3, 23],
[4, 5, 6, 25],
[7, 8, 9, 28],
[10, 11, 12, 41]])
```

We can find diagonal elements by the function diagonal and by using sum function we can find the sum of the elements.
```
print(matrix.diagonal())
print(matrix.diagonal().sum())
```

So the output comes as

[ 1 5 9 41] 56

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.

Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

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 predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

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

In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

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.