<jupyter_start><jupyter_text>KNN<jupyter_code>import numpy as np
# doing classification with KNN with 1 loop:

X_train = np.array([[1, 23 , 42, 54, 23, 53],
           [23, 78, 53, 2, 20, 12],
           [14, 32, 43, 65, 23, 20],
           [21, 76, 30, 87, 42, 12],
           [21, 56, 23, 76, 86, 43]])

X_test = np.array([[12, 54, 32, 67, 88, 55],
          [32, 45, 68, 97, 34, 23],
          [23, 75, 97, 45, 88, 65]])

num_te = X_test.shape[0]
num_tr = X_train.shape[0]

dists = np.zeros((num_te, num_tr))
for i in range(num_t):
    dists[i, :] = np.sqrt(np.sum(X_train - X_test[i, :])**2)
    
dists
dot = np.dot(X_test, X_train.T)
dot<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19047619047619047, 'fraction_numerical': 0.14583333333333334, 'mean_word_length': 2.7597765363128492, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '608800', 'license': 'MIT', 'n_tokens_mistral': 388, 'n_tokens_neox': 302, 'n_words': 81, 'path': 'CS231N/cs231n_tidbits.ipynb', 'repo_name': 'Hira63S/KnightRyder', 'size': '672'}