# The Role of Permutations and Combinations in Data Science

Permutation and combination are one of the most important topics of mathematics that has application in various domain such as machine learning, computer vision etc. In this article, we have discussed what it is, its formula, and how to calculate permutation and combination in python.

Permutation and Combination is an arrangement of a certain number of items. It is mainly concerned with determining the number of different ways of arranging and selecting objects from a given number of objects without actually listing them.

A permutation is all about the arrangement of a number of an object in a definite order, whereas a Combination is all about the selection of objects where order doesn’t matter.

In simple terms, permutation is an ordered selection. This article will briefly discuss all Permutations and Combinations, their formula, and their differences.

Let’s take an example to understand Permutation and Combination better.

Let there be three balls: A, B, and C. So find the Permutation and Combination.

**Case -1: Number of possibilities when order matters**

A B C**,** A C B**,** B C A**,** B A C**,** C B A**,** C A B

**Case – 2: Number of possibilities when order doesn’t matter**

A B C

So, the Permutation is 6, and the Combination is 1 (as all the item is arranged in one set since order doesn’t matter).

Now, let’s dive deep to better understand Permutation and Combination.

**Table of Content**

- What is Permutation and Combination
- Permutation and Combination Question
- Permutation and Combination in Python
- Difference between Permutation and Combination

**What is Permutation and Combination**

**Permutation**

A permutation is the number of ways to arrange items/objects given in a list taken, some or all at a time, in a specific order. In other words, a mathematical operation that is used to generate all the possible combinations of items of a set is called permutation.

It implies all the **possible arrangements or rearrangements** of a set into different orders.

**Example – 1:** Number of possibilities of four-digit lock.

**Example – 2:** Number of ways five students can sit on five chairs.

**Combination**

The combination is defined as the number of ways of selecting a group of an object from a set such that the order of selection does not matters.

The combination is all about grouping.

**Example – 1: **Picking finalists for a TV reality show.

**Example 2:** Selecting four toppings for pizza from the available ten toppings.

**Note: **

- In combination order of outcome does not matter.
- If the order is taken into consideration, then the combination will be the same as the number of permutations.

**Permutation and Combination Formula**

### **Permutation**

- The number of permutations on a set of
elements is given by*n*.*n*! - The number of ways of obtaining an ordered subset (permutation) of
*r*elements from the set of*n*elements is:

**Proof:**

Let we have to arrange *r* object from the list of *n* objects, and since in permutation the order of arrangement is important, so

1st element can be arranged in ** n** ways.

2nd element can be arranged in ** n-1** ways.

3rd element can be arranged in ** n-2** ways.

So, the ** r**-the element can be arranged in

**– (**

*n***– 1) ways =**

*r***ways**

*n – r +*1Hence, all the ** r**-element from the set of

**can be arranged in**

*n-elements*** n (n – 1) (n – 2) …. (n – r + 1)** ways, i.e.

Now, multiplying and dividing ** (n – r)** in numerator and denominator, respectively, we get:

**Example:** Find the number of permutation of {1, 2, 3}.

**Answer: **The number of permutation on a set of 3 elements will be 3! = 3 x 2 x 1 = 6, namely

{1, 2, 3}, {1, 3, 2}, {2, 3, 1}, {2, 1, 3}, {3, 2, 1}, {3, 1, 2}.

**Combination**

The number of ways of picking ** r** unordered outcomes from

**possibilities is:**

*n*C (n, r) = number of permutations/number of ways to arrange *r*

It is read as “** n** choose

**”.**

*r***Example:** Combination of 2 subsets from the set of {1, 2, 3, 4}.

**Answer: **

There are ^{4}C_{2} = 6, combinations of two elements that are form from the set of {1, 2, 3, 4}, namely

{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, and {3, 4}.

Programming Online Courses and Certification | Python Online Courses and Certifications |

Data Science Online Courses and Certifications | Machine Learning Online Courses and Certifications |

**Permutation and Combination Question**

**Example – 1: Let us have 15 cricket players, and we have to select 11 players for the final match. In how many ways can we select 11 players from the 15 players?**

**Answer**: In order to select the team, the order of selection doesn’t matter, and the players can’t be selected multiple times.

So, the number of ways the final 11 players can be selected from 15 players is as follows:

E**xample – 2: Handshake Problem**

**For a group of n people, how many different handshakes are possible.**

**Answer:**

** n**: Number of people in the group.

** r** = 2: number of people involved in each different handshake

Here, it doesn’t matter whom you handshake first, so for a group of 3 people, it will count:

1 with 2, 1 with 3, and 2 with 3, but we will not count 2 with 1, 3 with 1, and 3 with 2 as they are duplicates.

So, the total number of handshakes will be

Hence, total number of different handshakes will be **n(n-1)/2**.

**Permutation and Combination in Python**

**Example – 1: Print the python program to get all the permutation of [1, 2, 3, 4] of length 3.**

#Python program for Permutation
from itertools import permutations
permu = permutations([1, 2, 3, 4], 3)
#print the permutations
for i in list(permu): print(i)

**Output**

**Example – 2: Print the python program to get all the combination of [1, 2, 3, 4] of length 3.**

#Pyton program for Combination
from itertools import combinations
comb = combinations([1, 2, 3, 4], 3)
#print the obtained combinations
for i in list(comb): print(i)

**Output**

**Difference between Permutation and Combination**

Parameter |
Permutation |
Combination |

Definition |
Permutation is an arrangement of all members in order. | A combination is a selection of members from a collection or group. |

Represents |
Arrangement | Selection |

Order |
Values are arranged in an order. | Values are not arranged in any specific order. |

Derivation |
Multiple permutations from a single combination. | Single combination from a single permutation. |

Formula |
^{n}P_{r} = n!/(n-r)! |
^{n}C_{r} = n!/(r!)(n-r)! |

**Read Also:** Permutation vs. Combination

**Conclusion**

In this article, we have briefly discussed permutation and combinations, formula, and how to calculate it with the help of examples.

Hope you like the article.

**Top Trending Article**

Top Online Python Compiler | How to Check if a Python String is Palindrome | Feature Selection Technique | Conditional Statement in Python | How to Find Armstrong Number in Python | Data Types in Python | How to Find Second Occurrence of Sub-String in Python String | For Loop in Python |Prime Number | Inheritance in Python | Validating Password using Python Regex | Python List |Market Basket Analysis in Python | Python Dictionary | Python While Loop | Python Split Function | Rock Paper Scissor Game in Python | Python String | How to Generate Random Number in Python | Python Program to Check Leap Year | Slicing in Python

**Interview Questions**

Data Science Interview Questions | Machine Learning Interview Questions | Statistics Interview Question | Coding Interview Questions | SQL Interview Questions | SQL Query Interview Questions | Data Engineering Interview Questions | Data Structure Interview Questions | Database Interview Questions | Data Modeling Interview Questions | Deep Learning Interview Questions |

**About the Author**

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio