<jupyter_start><jupyter_text>brute linalg<jupyter_code>palettes = np.array(list(palette_dict.values()))
query_palette = palette_dict[np.random.choice(image_ids)]
np.linalg.norm((query_palette.reshape(5, 3)-palettes[0]), axis=1)
%%timeit
np.array(list(itertools.permutations(palettes[0])))
%%time
np.stack([list(itertools.permutations(palette)) for palette in palettes[:500]]).shape
%%time
big = np.stack([list(itertools.permutations(palette, 5)) for palette in palettes])
np.linalg.norm(big-query_palette, axis=3).sum(axis=2).min(axis=1)
np.linalg.norm(big-query_palette, axis=3).sum(axis=2).min(axis=1)
%%timeit
np.argsort(np.linalg.norm(big-query_palette, axis=3).sum(axis=2).min(axis=1))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18472222222222223, 'fraction_numerical': 0.025, 'mean_word_length': 10.092307692307692, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '315862', 'license': 'MIT', 'n_tokens_mistral': 303, 'n_tokens_neox': 298, 'n_words': 31, 'path': 'data_science/research/palette/notebooks/06 - vectorised assignment switching.ipynb', 'repo_name': 'TheStanfordDaily/loris-archives', 'size': '720'}