texthero/representation.py
def kmeans(s: pd.Series,
           n_clusters=5,
           init='k-means++',
           n_init=10,
           max_iter=300,
           tol=0.0001,
           precompute_distances='auto',
           verbose=0,
           random_state=None,
           copy_x=True,
           n_jobs=-1,
           algorithm='auto'):
    """
    Perform K-means clustering algorithm.
    """
    vectors = list(s)
    kmeans = KMeans(n_clusters=n_clusters,
                    init=init,
                    n_init=n_init,
                    max_iter=max_iter,
                    tol=tol,
                    precompute_distances=precompute_distances,
                    verbose=verbose,
                    random_state=random_state,
                    copy_x=copy_x,
                    n_jobs=n_jobs,
                    algorithm=algorithm).fit(vectors)
    return pd.Series(kmeans.predict(vectors), index=s.index)

    Perform K-means clustering algorithm.
    
Perform K-means clustering algorithm.
Perform K - means clustering algorithm .
def kmeans(s: pd.Series,
           n_clusters=5,
           init='k-means++',
           n_init=10,
           max_iter=300,
           tol=0.0001,
           precompute_distances='auto',
           verbose=0,
           random_state=None,
           copy_x=True,
           n_jobs=-1,
           algorithm='auto'):
    vectors = list(s)
    kmeans = KMeans(n_clusters=n_clusters,
                    init=init,
                    n_init=n_init,
                    max_iter=max_iter,
                    tol=tol,
                    precompute_distances=precompute_distances,
                    verbose=verbose,
                    random_state=random_state,
                    copy_x=copy_x,
                    n_jobs=n_jobs,
                    algorithm=algorithm).fit(vectors)
    return pd.Series(kmeans.predict(vectors), index=s.index)
def kmeans ( s : pd . Series , n_clusters = 5 , init = 'k-means++' , n_init = 10 , max_iter = 300 , tol = 0.0001 , precompute_distances = 'auto' , verbose = 0 , random_state = None , copy_x = True , n_jobs = - 1 , algorithm = 'auto' ) : vectors = list ( s ) kmeans = KMeans ( n_clusters = n_clusters , init = init , n_init = n_init , max_iter = max_iter , tol = tol , precompute_distances = precompute_distances , verbose = verbose , random_state = random_state , copy_x = copy_x , n_jobs = n_jobs , algorithm = algorithm ) . fit ( vectors ) return pd . Series ( kmeans . predict ( vectors ) , index = s . index )
Perform K-means clustering algorithm.
Perform K - means clustering algorithm .
"""
    Perform K-means clustering algorithm.
    """
s
pd.Series
n_clusters
init
n_init
max_iter
tol
precompute_distances
verbose
random_state
copy_x
n_jobs
algorithm