K-means clustering algorithm in python

I'm looking for a package to use K-means clustering algorithm in python.

I need just to run clustering algorithm in python from other environment, which is writen in another language.

pythonunsupervised-learningk-meansclustering
3 votesJW229.00
1 Answers
JO218.00
3

For running a clustering algorithm from another environment, you can use any package writen in python.
The only thing you should consider, is how you're going to connect those 2 pieces.

You can use different approaches for connecting 2 pieces like

  1. Rest API
  2. Socket Connection
  3. GRPC
  4. etc.

and about k-means clustering algorithm: you can take scikit-learn implementation, which gives you a simple API to do it

from sklearn.cluster import KMeans
import numpy as np

X = np.array([[1, 2], [1, 4], [1, 0],
        [10, 2], [10, 4], [10, 0]])

kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
kmeans.labels_  # labels for the cluster
kmeans.cluster_centers_  # centroids for every cluster
kmeans.predict([p1, p2]) # predict the cluster for the points
Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?