Code Monkey home page Code Monkey logo

k-means-clustering-algorithm's Introduction

Implementation of K-Means Clustering Algorithm

Aim

To write a python program to implement K-Means Clustering Algorithm.

Equipment’s required:

  1. Hardware – PCs
  2. Anaconda – Python 3.7 Installation

Algorithm:

Step1

Import the necessary packages.

Step2

Read the csv file.

Step3

Scatter plot the applicant income and loan amount.

Step4

Obtain the kmean clustring for 2 classes.

Step5

Pretict the cluster group of Applicant Income and Loanamount.

Program:

Developed By: Jegathish s
Roll no: 21005410

import pandas as pd
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
import seaborn as sns
x1=pd.read_csv("clustering.csv")
print(x1.head(2))
x2=x1.loc[:,["ApplicantIncome",'LoanAmount']]
print(x2.head(2))

x=x2.values
#print(x)
sns.scatterplot(x[:,0],x[:,1])
plt.xlabel("Income")
plt.ylabel('Loan')
plt.show()

Kmeans=KMeans(n_clusters=4)
kmeans.fit(x)
print("cluster centers:",kmeans.cluster_centers_)
print("Labes:",kmeans.labels_)
predict_class = kmeans.predict([[9000,1200]])
print("Cluster group for application income 9000 and loanamount 120 is",predict_class)

Output:

Insert your output

output

Result

Thus the K-means clustering algorithm is implemented and predicted the cluster class using python program.

k-means-clustering-algorithm's People

Contributors

etjabajasphin avatar jegathish-16 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.