<jupyter_start><jupyter_text>Tugas Besar IF4074 Pembelajaran Mesin Lanjut ClusteringAnggota Kelompok1. <NAME> - 135160522. <NAME> - 135160783. <NAME> - 13516152<jupyter_code># General Library
import pandas as pd
import numpy as np

# Clustering Implementation
from KMeans import KMeans
# from dbscan import DBSCAN
from Metric import Metric

# Sklearn Library
from sklearn import datasets

from sklearn.cluster import KMeans as sklearn_KMeans
from sklearn.cluster import AgglomerativeClustering as sklearn_AgglomerativeClustering
from sklearn.cluster import DBSCAN as sklearn_DBSCAN

from sklearn.model_selection import KFold
from sklearn.model_selection import train_test_split
iris = datasets.load_iris()
X = iris.data
y = iris.target
kf = KFold(n_splits=2, shuffle=True)
sk_kmeans = sklearn_KMeans(n_clusters=3)
kmeans = KMeans(3)
for train_index, test_index in kf.split(X):
    X_train, y_train = X[train_index], y[train_index]
    X_test, y_test = X[test_index], y[test_index]
    kmeans.fit(X_train)
    sk_kmeans.fit(X_train)
    result = kmeans.predict(X_test)
    sk_result = sk_kmeans.predict(X_test)
    metric = Metric(result, 3)
    print ()
    metric = Metric(sk_result, 3)
    print ()
    print ('Result')
    print (result)
    print (sk_result)
    print (y_test)<jupyter_output>Cluster 1 -> class 0: 7, class 1: 0, class 2: 0
Cluster 2 -> class 0: 19, class 1: 25, class 2: 0
Cluster 3 -> class 0: 24, class 1: 0, class 2: 0

Cluster 1 -> class 0: 24, class 1: 0, class 2: 0
Cluster 2 -> class 0: 1, class 1: 14, class 2: 0
Cluster 3 -> class 0: 25, class 1: 11, class 2: 0

Result
[2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 0 1 0 1 1 1 0 1 1 1
 1 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 1 2 1 2 2 1 1 1 1 1 2 1 1 2 1 2 1 2 1
 2]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2]
Cluster 1 -> class 0: 24, class 1: 25, class 2: 0
Cluster 2 -> class 0: 0, class 1: 0, class 2: 0
Cluster 3 -> class 0: 26, class 1: 0, class 2: 0

Cluster 1 -> class 0: 26, class 1: 0, class 2: 0
Cluster 2 -> class 0: 8, class 1: 25,[...]
{'fraction_non_alphanumeric': 0.08340573414422242, 'fraction_numerical': 0.15117289313640314, 'mean_word_length': 2.877104377104377, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '452590', 'license': 'MIT', 'n_tokens_mistral': 1259, 'n_tokens_neox': 912, 'n_words': 461, 'path': 'Pengujian.ipynb', 'repo_name': 'deborrrrrah/Clustering', 'size': '2354'}