Zip It! - Finding File Similarity Using Compression Utilities - Computerphile

Computerphile · Advanced ·📄 Research Papers Explained ·1y ago

Key Takeaways

The video discusses using file compression utilities to find file similarity, specifically in the context of genome comparison and phylogenetic tree construction, referencing research papers on similarity and entropy.

Full Transcript

All right. So, I want to tell you about one of my one of my favorite little computer science thingies. Uh, so the question is suppose you want to find the phoggenetic tree uh of a bunch of different types of animals and or different plants given their genomes and all you have is file compression utilities. All right. So, what's a file compression utility? So, you might be familiar with zip files. Um, like zip is the classic file compression utility. So zip files are lossless compression by which I mean when you unzip you get exactly the same file that you had on the way in. So this is in in contrast to for example JPEG which is a lossy compression format where the JPEG file it looks pretty good but it's lost a lot of data and it's not going to look exactly the same as the original. To use a demonstration this is a flower picture that I took and this picture on the right has had the chronence components down sampled by a factor of 10 in both directions. There's 100 times less color in this picture than there is in this one. But for zip files because they're trying to be completely generic, you can't just throw away data. And basically what zip does is it gives us this function C which takes a bunch of content in a file and you know maps that into a into a bunch of bitst string you know a compressed form. And how does it do this? Uh well what it does is it looks for repeated patterns in this bit sequence. it uses a pointer and in that composite pointer it points back to where the phrase first occurred >> and then when it sees repeated patterns uh instead of having to write it out again it can just write a reference to the previous place where it had that pattern and say oh yeah we do that part again. So there's a lot of compression algorithms with a lot of them end up being very complicated because it's very important to have good compression algorithms. But you can basically you can sort of use uh the length of a compressed file as a measure of the complexity of the file. So if a file is really long but most of it is just repetitive uh its compressed form is going to be very short. So the ratio between the length of the compressed file and the original file is telling you something about how complicated the file is. So here's a second thing we can do. If I have two files X and Y, for example, the human genome and the chimpanzeee genome, one thing we can do is we could consider uh the length of compress X uh and the length of compress Y. So this is saying we take the human genome and compress it and take its length and add that to the length of the compressed chimp genome and that's going to give us some length. Now here's something else we can do. If we can consider the length of the compression of the human genome plus the chimp genome. So when I say plus on genomes I just mean literally you concatenate the text files like you have a text file on your computer containing the human genome and a text file on your computer containing the chimpanzeee genome and you just copy paste one into the end of the other and now you have a new text file and you can compress it and see what its length is. So here's the idea. Suppose an x and y were literally the same. the length of the compression of x + y is going to be almost the same as the length of the compression of just x because when you get to the second file, you're just going to write down like and then do all of that again. >> Yes. >> Uh and if x and y are completely unrelated, then there's going to be no reduction. C of x plus y is going to have the same length as these these two different compressed files compressed separately. Mhm. >> So you can use this idea to basically get a metric of similarity on arbitrary data uh just by compressing concatenated versions of the files and comparing that to the length if you compress them separately. And this is just an extremely generic method. You can do it to a bunch of different things. This here is a phoggenetic tree of how CO compares to a bunch of different virus variants. I have uh some different methods of applying this to different kinds of animals and you can basically see the evolutionary history of all these animals just using the off-the-shelf compression algorithms. When I did this um when I was in college, I think I just used whatever compression algorithm was on the Linux machine I was using. It it it just works like pretty reliably. Another thing you can do suppose you want to know uh you know languages come in families and languages have these family trees. So one thing you can do is just take the UN declaration of human rights which has been translated to many different languages and take all the ones that use you know um the western alphabet the Roman alphabet uh and just apply this method directly uh and you get a not perfect but pretty reasonable depiction of the the history of all these languages. So I just think this is a super cute method in practice. I don't think this is very important for anything because if you actually care about any domain you might as well write a better similarity metric than gzipping them. But it's uh it's fun that it is so general and and works reasonably well. A partition like this. Four bits here, 12 bits here. 2 to the^ 12 is 4,096. Note to those of you that keep writing in on comments saying, "Hey, professor, what should I do? I'm just So if we look at B, we've already been to S, so we ignore it. We can go to D.

Original Description

Finding Genome similarity can just be a case of zipping the relevant files in the right order. Buck Shlegeris is CEO of Redwood Research Papers: https://homepages.cwi.nl/~paulv/papers/similarity.pdf https://pmc.ncbi.nlm.nih.gov/articles/PMC9030035/#sec4-entropy-24-00439 Computerphile is supported by Jane Street. Learn more about them (and exciting career opportunities) at: https://jane-st.co/computerphile This video was filmed and edited by Sean Riley. Computerphile is a sister project to Brady Haran's Numberphile. More at https://www.bradyharanblog.com
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Computerphile · Computerphile · 0 of 60

← Previous Next →
1 Follow the Cookie Trail - Computerphile
Follow the Cookie Trail - Computerphile
Computerphile
2 EXTRA BITS - Follow the Cookie Trail - Computerphile
EXTRA BITS - Follow the Cookie Trail - Computerphile
Computerphile
3 Musical Floppy Drives - Computerphile
Musical Floppy Drives - Computerphile
Computerphile
4 The Hair Algorithm - Computerphile
The Hair Algorithm - Computerphile
Computerphile
5 Getting Sorted & Big O Notation - Computerphile
Getting Sorted & Big O Notation - Computerphile
Computerphile
6 Quick Sort - Computerphile
Quick Sort - Computerphile
Computerphile
7 Hyper History and Cyber War - Computerphile
Hyper History and Cyber War - Computerphile
Computerphile
8 Entropy in Compression - Computerphile
Entropy in Compression - Computerphile
Computerphile
9 Original Elite on the BBC B - Computerphile
Original Elite on the BBC B - Computerphile
Computerphile
10 IP Addresses and the Internet - Computerphile
IP Addresses and the Internet - Computerphile
Computerphile
11 A Career in Video Games - Computerphile
A Career in Video Games - Computerphile
Computerphile
12 Error Detection and Flipping the Bits - Computerphile
Error Detection and Flipping the Bits - Computerphile
Computerphile
13 Programming BASIC and Sorting - Computerphile
Programming BASIC and Sorting - Computerphile
Computerphile
14 Birthplace of the World Wide Web - Computerphile
Birthplace of the World Wide Web - Computerphile
Computerphile
15 Punch Card Programming - Computerphile
Punch Card Programming - Computerphile
Computerphile
16 Programming Paradigms - Computerphile
Programming Paradigms - Computerphile
Computerphile
17 CERN Computing Centre (and mouse farm) - Computerphile
CERN Computing Centre (and mouse farm) - Computerphile
Computerphile
18 Error Correction - Computerphile
Error Correction - Computerphile
Computerphile
19 Home-Made Code - Computerphile
Home-Made Code - Computerphile
Computerphile
20 Security of Data on Disk - Computerphile
Security of Data on Disk - Computerphile
Computerphile
21 Gesture Controls - Computerphile
Gesture Controls - Computerphile
Computerphile
22 How Intelligent is Artificial Intelligence? - Computerphile
How Intelligent is Artificial Intelligence? - Computerphile
Computerphile
23 Encryption and Security Agencies - Computerphile
Encryption and Security Agencies - Computerphile
Computerphile
24 Virtual Machines Power the Cloud - Computerphile
Virtual Machines Power the Cloud - Computerphile
Computerphile
25 Hacking Websites with SQL Injection - Computerphile
Hacking Websites with SQL Injection - Computerphile
Computerphile
26 How Huffman Trees Work - Computerphile
How Huffman Trees Work - Computerphile
Computerphile
27 Cracking Websites with Cross Site Scripting - Computerphile
Cracking Websites with Cross Site Scripting - Computerphile
Computerphile
28 Cloud Computing (Cloudy with a Chance of Pizza) - Computerphile
Cloud Computing (Cloudy with a Chance of Pizza) - Computerphile
Computerphile
29 Texting Cabbage with a Recorder - Computerphile
Texting Cabbage with a Recorder - Computerphile
Computerphile
30 Hashing Algorithms and Security - Computerphile
Hashing Algorithms and Security - Computerphile
Computerphile
31 How YouTube Works - Computerphile
How YouTube Works - Computerphile
Computerphile
32 How NOT to Store Passwords! - Computerphile
How NOT to Store Passwords! - Computerphile
Computerphile
33 A New Golden Age of Video Games - Computerphile
A New Golden Age of Video Games - Computerphile
Computerphile
34 A Universe of Triangles - Computerphile
A Universe of Triangles - Computerphile
Computerphile
35 Cross Site Request Forgery - Computerphile
Cross Site Request Forgery - Computerphile
Computerphile
36 The True Power of the Matrix (Transformations in Graphics) - Computerphile
The True Power of the Matrix (Transformations in Graphics) - Computerphile
Computerphile
37 The Great 202 Jailbreak - Computerphile
The Great 202 Jailbreak - Computerphile
Computerphile
38 EXTRA BITS - Printing and Typesetting History - Computerphile
EXTRA BITS - Printing and Typesetting History - Computerphile
Computerphile
39 Triangles to Pixels - Computerphile
Triangles to Pixels - Computerphile
Computerphile
40 The Problem with Time & Timezones - Computerphile
The Problem with Time & Timezones - Computerphile
Computerphile
41 The Visibility Problem - Computerphile
The Visibility Problem - Computerphile
Computerphile
42 Lights and Shadows in Graphics - Computerphile
Lights and Shadows in Graphics - Computerphile
Computerphile
43 The Penguin Barcode - Computerphile
The Penguin Barcode - Computerphile
Computerphile
44 Typesetters in the '80s - Computerphile
Typesetters in the '80s - Computerphile
Computerphile
45 The Font Magicians - Computerphile
The Font Magicians - Computerphile
Computerphile
46 The Little Mac with the Big Bite - Computerphile
The Little Mac with the Big Bite - Computerphile
Computerphile
47 EXTRA BITS - More on the Original Mac at 30 - Computerphile
EXTRA BITS - More on the Original Mac at 30 - Computerphile
Computerphile
48 XP to Ubuntu with an 8yr old Hacktop - Computerphile
XP to Ubuntu with an 8yr old Hacktop - Computerphile
Computerphile
49 EXTRA BITS - Hacktop Real-Time Boot Comparison - Computerphile
EXTRA BITS - Hacktop Real-Time Boot Comparison - Computerphile
Computerphile
50 EXTRA BITS - Making a Bootable USB in Linux - Computerphile
EXTRA BITS - Making a Bootable USB in Linux - Computerphile
Computerphile
51 EXTRA BITS - Installing Ubuntu Permanently - Computerphile
EXTRA BITS - Installing Ubuntu Permanently - Computerphile
Computerphile
52 The Dawn of Desktop Publishing - Computerphile
The Dawn of Desktop Publishing - Computerphile
Computerphile
53 What is Bootstrapping? - Computerphile
What is Bootstrapping? - Computerphile
Computerphile
54 Reverse Polish Notation and The Stack - Computerphile
Reverse Polish Notation and The Stack - Computerphile
Computerphile
55 Home-Made Z80 Retro Computer - Computerphile
Home-Made Z80 Retro Computer - Computerphile
Computerphile
56 Should Everybody Learn to Code? - Computerphile
Should Everybody Learn to Code? - Computerphile
Computerphile
57 Programming in PostScript - Computerphile
Programming in PostScript - Computerphile
Computerphile
58 Heartbleed, Running the Code - Computerphile
Heartbleed, Running the Code - Computerphile
Computerphile
59 YouTube's Secret Algorithm - Computerphile
YouTube's Secret Algorithm - Computerphile
Computerphile
60 YouTube Search & Discovery - Computerphile
YouTube Search & Discovery - Computerphile
Computerphile

The video teaches how to use file compression utilities to find file similarity, specifically in genome comparison and phylogenetic tree construction, and discusses the concept of similarity metrics. This method can be applied to various domains, including bioinformatics and natural language processing.

Key Takeaways
  1. Understand the concept of lossless compression and compression algorithms
  2. Apply the method of compressing concatenated files to measure similarity
  3. Use the length of compressed files as a metric of complexity
  4. Compare the length of compressed files to the length of compressed concatenated files
💡 The method of using file compression utilities to find file similarity is a general and simple approach that can be applied to various domains, but may not be the most accurate or efficient method for specific domains.

Related Reads

Up next
Welcome to the Next Temperamental Era
Charles Schwab
Watch →