<jupyter_start><jupyter_text>PCA has reduced the number of features from 98 to 74 keeping a %90 explained variance ratio.<jupyter_code># Run t-SNE
tsne = TSNE(learning_rate=250)
tsne_features = tsne.fit_transform(pc_pca)
# plot the t-SNE output
df_tsne=pd.DataFrame(tsne_features,columns=['x','y'])
df_tsne.plot(kind='scatter',x='x',y='y')
plt.show()
# Finding the best value for k
inertia = []
k = list(range(1, 11))

# Calculate the inertia for the range of k values
for i in k:
    km = KMeans(n_clusters=i, random_state=0)
    km.fit(df_tsne)
    inertia.append(km.inertia_)

# Create a data frame to hold the data for the elbow curve
elbow_data = {"k": k, "inertia": inertia}
df_elbow = pd.DataFrame(elbow_data)
df_elbow.head()
# Plot the elbow curve to find the best candidate(s) for k
plt.plot(df_elbow['k'], df_elbow['inertia'])
plt.xticks(range(1,11))
plt.xlabel('Number of clusters')
plt.ylabel('Inertia')
plt.title('Elbow curve for crypto data')
plt.show()
# Initialize the K-Means model and visualize the clusters
model = KMeans(n_clusters=4, random_state=0)
model.fit(df_tsne)
predictions = model.predict(df_tsne)
df_tsne.plot(kind='scatter',x='x',y='y',colormap='viridis',c=predictions, )
plt.show()
import warnings
warnings.simplefilter("ignore")
df_mined['class']=model.labels_
df_mined<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13963963963963963, 'fraction_numerical': 0.013513513513513514, 'mean_word_length': 6.446927374301676, 'pattern_counts': {'":': 2, '<': 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': '350875', 'license': 'ADSL', 'n_tokens_mistral': 534, 'n_tokens_neox': 506, 'n_words': 123, 'path': 'crypto_data_ML.ipynb', 'repo_name': 'NazihZaz/Cryptocurrency-Clusters-Unsupervised-Learning-Challenge', 'size': '1332'}