<jupyter_start><jupyter_text>Load Digit Datset<jupyter_code>digits = load_digits()<jupyter_output><empty_output><jupyter_text>Try sklearn's TSNE<jupyter_code>tsne_sk = TSNE(n_components=2, perplexity=30, random_state=17)
x_tsne = tsne_sk.fit_transform(digits.data)
def plot_tsne(X, y):
    fig = plt.figure(1, figsize=(8, 8))
    plt.scatter(X[:, 0], X[:, 1],
            c=y, edgecolor='none', alpha=0.5,
            cmap=plt.cm.get_cmap('tab10', 10))
    plt.xlabel('component 1')
    plt.ylabel('component 2')
    plt.colorbar()
    plt.show();
plot_tsne(x_tsne, digits.target)
import pandas as pd
df = pd.DataFrame(columns=['1', '2', 'target'])
df['1'] = x_tsne[:, 0]
df['2'] = x_tsne[:, 1]
df['target'] = digits.target
plt.figure(figsize=(8, 8))
sns.scatterplot(
    x='1', y='2',
    hue='target',
    palette=sns.color_palette("hls", 10),
    data=df,
    legend="full",
    alpha=0.3
)<jupyter_output><empty_output><jupyter_text>Our Implementation<jupyter_code>tsne_my = tsne(n_components=2, perplexity=30, random_seed=17)
x_tsne_my = tsne_my.fit_transform(digits.data)
plot_tsne(x_tsne_my, digits.target)
df = pd.DataFrame(columns=['1', '2', 'target'])
df['1'] = x_tsne_my[:, 0]
df['2'] = x_tsne_my[:, 1]
df['target'] = digits.target
plt.figure(figsize=(8, 8))
sns.scatterplot(
    x='1', y='2',
    hue='target',
    palette=sns.color_palette("hls", 10),
    data=df,
    legend="full",
    alpha=0.3
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1927877947295423, 'fraction_numerical': 0.03536754507628294, 'mean_word_length': 5.219827586206897, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '238458', 'license': 'MIT', 'n_tokens_mistral': 652, 'n_tokens_neox': 620, 'n_words': 95, 'path': 'tSNE/t-SNE.ipynb', 'repo_name': 'nachiket273/ML_Algo_Implemented', 'size': '1442'}