<jupyter_start><jupyter_text>Clustering ← ↑`Description`--- Setup---<jupyter_code>from __init__ import init_vars
init_vars(vars(), ('info', {}))

from sklearn.metrics.cluster import normalized_mutual_info_score, adjusted_rand_score

import data
import config
from base import nbprint
from util import ProgressIterator
from widgetbase import nbbox

from metrics.widgets import h_mat_picker
from metrics.helper import load_ground_truth_classes, load_class_array_from_h_mat

if RUN_SCRIPT: h_mat_picker(info)<jupyter_output><empty_output><jupyter_text>--- NMI---`Definition`<jupyter_code>def nmi(labels_true, labels_pred):
    return normalized_mutual_info_score(labels_true, labels_pred)<jupyter_output><empty_output><jupyter_text>--- ARI---`Definition`<jupyter_code>def ari(labels_true, labels_pred):
    return adjusted_rand_score(labels_true, labels_pred)<jupyter_output><empty_output><jupyter_text>--- Show all---<jupyter_code>if RUN_SCRIPT:
    nbbox(mini=True)
    labels_true = load_ground_truth_classes(info)
    labels_pred = load_class_array_from_h_mat(info)
    
    nbprint('NMI score: {}'.format(nmi(labels_true, labels_pred)))
    nbprint('ARI score: {}'.format(ari(labels_true, labels_pred)))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11093117408906883, 'fraction_numerical': 0.0, 'mean_word_length': 7.828571428571428, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '410415', 'license': 'MIT', 'n_tokens_mistral': 445, 'n_tokens_neox': 427, 'n_words': 70, 'path': 'tomef/metrics/clustering.py.ipynb', 'repo_name': 'unlikelymaths/tomef', 'size': '1235'}