Giter Club home page Giter Club logo

evaluation-a-clustering's Introduction

evaluation-a-clustering

evaluation a clustering

inertia :distance from each sample to centroids of its cluster or how spread out the clusters. (Lower is better)

we evaluate our clustring with see the process of the inersia chart now it is the time to have the code

# import requirements
import numpy as np
from sklearn.datasets import load_iris
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
iris = load_iris()
# now we calculate the inertia for 15 diffrent "n_clusters" to find the best one 
inertia_list = []
for k in np.arange(1, 15):
 kmn = KMeans(n_clusters=k)
 kmn.fit(iris.data)
 inertia_list.append(kmn.inertia_)
# draw the chart
plt.plot(np.arange(1,15),inertia_list,'ro-')
plt.xlabel('number of clusters')
plt.ylabel('Inertia')
plt.show()

if you look at the chart you can see, it is descending chart and maybe you think it is good to set cluster as large number but in this case, you don't consider the complexity of our model, it is very import to make a simple model so you should choose the amount which is logical for our goal(in this case it is three ⭐⭐⭐)

I hope this article will be useful to you.

evaluation-a-clustering's People

Contributors

azibom avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.