Sometimes, while working with Python list, we have a problem in which we need to find how much a list is similar to other list. The similarity quotient of both the list is what is required in many scenarios we might have. Let’s discuss a way in which this task can be performed.
Method : Using
"|" operator + "&" operator + set()
The method which is formally applied to calculate the similarity among lists is finding the distinct elements and also common elements and computing it’s quotient. The result is then multiplied by 100, to get the percentage.
The original list 1 is : [1, 4, 6, 8, 9, 10, 7] The original list 2 is : [7, 11, 12, 8, 9] Percentage similarity among lists is : 33.33333333333333
- Python | Measure similarity between two sentences using cosine similarity
- Python | Word Similarity using spaCy
- Python | Similarity metrics of strings
- Python | Test list element similarity
- Python | Percentage occurrence at index
- Python | Sort a list of percentage
- Python | Program to count number of lists in a list of lists
- Python | Percentage increase in the total surface area of the cuboid
- Python | Percentage increase in hemisphere volume if radius is increased
- Python | Zipping two lists of lists
- NLP | WuPalmer - WordNet Similarity
- NLP | Leacock Chordorow (LCH) and Path similarity for Synset
- Python | Union of Value Lists
- Python | Using 2D arrays/lists the right way
- Python | All possible permutations of N lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.