memesearch
Python Code for Text Classification

Python Code for Text Classification

Download Find similar pictures
Text on the meme
1 import gzip 2 import numpy as np 3 for (x1, _) in test_set: 4 Cx1 = len(gzip.compress(x1.encode())) 5 distance_from_x1 = [] 6 for (x2, _) in training_set: 7 Cx2 = len(gzip.compress(x2.encode())) 8 x1x2 = " ".join([x1, x2]) 9 Cx1x2 = len(gzip.compress(x1x2.encode())) 10 ncd = (Cx1x2 - min(Cx1, Cx2)) / max( Cx1, Cx2) 11 distance_from_x1.append(ncd) 12 sorted_idx = np.argsort(np.array( distance_from_x1)) 13 top_k_class = training_set[sorted_idx [:k], 1] 14 predict_class = max(set(top_k_class), key=top_k_class.count) Listing 1: Python Code for Text Classification with gzip.
What it means

The image shows a monospaced Python code listing that classifies text by comparing gzip compression distances between test and training examples, then choosing the most common class among the nearest matches. The joke is the absurdly technical appearance of the code and its use as a reaction to overly complicated machine-learning or programming discussions. EN: The image shows a monospaced Python code listing that classifies text by comparing gzip compression distances between test and training examples, then choosing the most common class among the nearest matches. The joke is the absurdly technical appearance of the code and its use as a reaction to overly complicated machine-learning or programming discussions.

Objects
Tags
Source
Type
image
Size
732×800 · 102.1 KiB
Mood
технический абсурд
Language
en
Added