Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kmeans error: __init__() got an unexpected keyword argument 'precompute_distances' #218

Open
ostwaldj opened this issue Dec 25, 2021 · 3 comments

Comments

@ostwaldj
Copy link

Created a new virtual env with only Texthero and its dependencies installed. A year or more ago it worked, but now when I try to run kmeans, e.g.
.pipe(hero.kmeans,n_clusters=5)
it errors:
init() got an unexpected keyword argument 'precompute_distances'

This happens with my own data and code, and also when I paste the BBCSport sample code in as well.

@PhelaPoscam
Copy link

PhelaPoscam commented Feb 2, 2022

Same problem.

Seems like sklearn.cluster.KMeans dont use precompute_distances anymore

https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html?highlight=kmeans#sklearn.cluster.KMeans

You can comment the lines "precompute_distances="auto"" and "#n_jobs=n_jobs," in representation.py and will work

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)

@anu43
Copy link

anu43 commented Dec 8, 2022

it's still present. when could it be re-evaluated?

@jbesomi
Copy link
Owner

jbesomi commented Dec 9, 2022

Thanks for letting me know. I will look into that in the next few days and release a new version to fix that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants