<commit_before>"""Class to perform under-sampling by generating centroids based on
clustering."""
from __future__ import division, print_function

from collections import Counter

import numpy as np
from sklearn.cluster import KMeans

from ..base import BaseMulticlassSampler


class ClusterCentroids(BaseMulticlassSampler):
    """Perform under-sampling by generating centroids based on
    clustering methods.

    Experimental method that under samples the majority class by replacing a
    cluster of majority samples by the cluster centroid of a KMeans algorithm.
    This algorithm keeps N majority samples by fitting the KMeans algorithm
    with N cluster to the majority class and using the coordinates of the N
    cluster centroids as the new majority samples.

    Parameters<commit_msg>DOC remove the term experimental (#268)<commit_after>"""Class to perform under-sampling by generating centroids based on
clustering."""
from __future__ import division, print_function

from collections import Counter

import numpy as np
from sklearn.cluster import KMeans

from ..base import BaseMulticlassSampler


class ClusterCentroids(BaseMulticlassSampler):
    """Perform under-sampling by generating centroids based on
    clustering methods.

    Method that under samples the majority class by replacing a
    cluster of majority samples by the cluster centroid of a KMeans
    algorithm.  This algorithm keeps N majority samples by fitting the
    KMeans algorithm with N cluster to the majority class and using
    the coordinates of the N cluster centroids as the new majority
    samples.

    Parameters
{'fraction_non_alphanumeric': 0.0327970297029703, 'fraction_numerical': 0.0018564356435643563, 'mean_word_length': 4.39, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '123621', 'n_tokens_mistral': 395, 'n_tokens_neox': 376, 'n_words': 199}