<jupyter_start><jupyter_text>K Means Cluster<jupyter_code>from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=2)
kmeans.fit(df.drop('Private', axis=1))
kmeans.cluster_centers_<jupyter_output><empty_output><jupyter_text>Evaluation<jupyter_code>def converter(private):
    if private == 'Yes':
        return 1
    else:
        return 0        
df['Cluster'] = df['Private'].apply(converter)
df.head()
from sklearn.metrics import classification_report, confusion_matrix
print(classification_report(kmeans.labels_, df['Cluster']))
print(confusion_matrix(df['Cluster'], kmeans.labels_))<jupyter_output>precision    recall  f1-score   support

           0       0.65      0.21      0.31       669
           1       0.06      0.31      0.10       108

    accuracy                           0.22       777
   macro avg       0.36      0.26      0.21       777
weighted avg       0.57      0.22      0.28       777

[[138  74]
 [531  34]]
{'fraction_non_alphanumeric': 0.1038135593220339, 'fraction_numerical': 0.07521186440677965, 'mean_word_length': 2.3392226148409896, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '207192', 'license': 'MIT', 'n_tokens_mistral': 355, 'n_tokens_neox': 313, 'n_words': 64, 'path': 'K Means Clustering/Project.ipynb', 'repo_name': 'anishjain18/ML-codes', 'size': '944'}