MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to create a n by n identity matrix in numpy?

# How to create a n by n identity matrix in numpy?

This recipe helps you create a n by n identity matrix in numpy

Identity matrix are ones having diagonal elements to 1 and rest of elemets to be 0.

So this recipe is a short example on how to create a n by n identity matrix. Let's get started.

```
def identity(n):
m=[[0 for x in range(n)] for y in range(n)]
for i in range(0,n):
m[i][i] = 1
return m
```

In 2nd line, we have created a 0 matrix of size n by n. Thereby, using for loop, updating the diagonal elements.

```
print(identity(3))
```

We are calling identiy function of 3 by 3 matrix. Input needed for the function was 3.

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

[[1, 0, 0], [0, 1, 0], [0, 0, 1]]

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.

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

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

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 Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

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

Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

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 data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.