0% found this document useful (0 votes)
73 views

Assignment#3 AI

K-means clustering and fuzzy c-means clustering are both commonly used unsupervised learning algorithms. K-means clustering assigns each data point definitively to one cluster, while fuzzy c-means clustering allows each point to belong to multiple clusters with varying degrees of membership between 0 and 1. Fuzzy c-means clustering is generally better able to handle noise and inconsistencies in data compared to hard assignments of k-means. Both algorithms aim to optimize clustering by minimizing distances between points and cluster centroids, but fuzzy c-means clustering accounts for partial membership across clusters in its optimization approach.

Uploaded by

Taimoor ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Assignment#3 AI

K-means clustering and fuzzy c-means clustering are both commonly used unsupervised learning algorithms. K-means clustering assigns each data point definitively to one cluster, while fuzzy c-means clustering allows each point to belong to multiple clusters with varying degrees of membership between 0 and 1. Fuzzy c-means clustering is generally better able to handle noise and inconsistencies in data compared to hard assignments of k-means. Both algorithms aim to optimize clustering by minimizing distances between points and cluster centroids, but fuzzy c-means clustering accounts for partial membership across clusters in its optimization approach.

Uploaded by

Taimoor ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Artificial Intelligence

Rao Taimoor Ali


70067696
Section -7D
Assignment # 3

Q1. Assignment is more related to Unsupervised learning; in this learning we had studies KMEAN, FCM
algorithm, you work is to write the algorithm of KMEAN for application, application can be implementation
in any field like medical imaging, security purpose etc. After writing algorithm you must write the program
in which we should be able to check all steps of KMEAN.

Ans: Image segmentation is an important technique for image processing which aims at
partitioning the image into different homogeneous regions or clusters. Segmentation of the MRI
images is very important and crucial for the exact diagnosis by computer aided clinical tools. A
large variety of algorithms for segmentation of MRI images had been developed. However most
of these have some limitations, to overcome these limitations; modified k means clustering is
proposed. The comparison of existing segmentation approaches such as C-Means Clustering, K-
Means Clustering with Modified K-Means Clustering is performed then the performance
evaluated.

K-means is one of the simplest unsupervised learning algorithms that solve the well
known clustering problem. The procedure follows a simple and easy way to classify a given
data set through a certain number of clusters.

Applications of K-means clustering:

K-means clustering can be used in almost every domain, ranging from banking to
recommendation engines, cyber security, document clustering to image segmentation. It is
typically applied to data that has a smaller number of dimensions, is numeric, and is
continuous.

K-Means Clustering can also be used for performing image segmentation by trying to group
similar pixels in the image together and creating clusters. The different clusters formed are
different objects in an image.
K-means is an iterative algorithm in which it minimizes the sum of
distances from each object to its cluster centroid, over all clusters.
Let us consider an image with resolution of x×y and the image has to be cluster into k number of
cluster. Let p(x, y)
be an input pixels to be cluster and ck be the cluster centers. The algorithm for k-means13
clustering is following as:
1. Initialize number of cluster k and centre.
2. For each pixel of an image, calculate the Euclidean distance d, between the center and each
pixel of an image
using the relation given below.

d = _p(x, y) − ck_ (3)


3. Assign all the pixels to the nearest centre based on distance d.
4. After all pixels have been assigned, recalculate new position of the centre using the relation
given below.
ck = 1
k
_
y∈ck
_
x∈ck
p(x, y) (4)
5. Repeat the process until it satisfies the tolerance or error value.
6. Reshape the cluster pixels into image.

Program in which we should be able to check all steps of KMEAN.

import numpy as np

import cv2

from matplotlib import pyplot as plt

X = np.random.randint(10,45,(25,2))

Y = np.random.randint(55,70,(25,2))
Z = np.vstack((X,Y))

# convert to np.float32

Z = np.float32(Z)

# define criteria and apply kmeans()

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)

ret,label,center = cv2.kmeans(Z,2,None,criteria,10,cv2.KMEANS_RANDOM_CENTERS)

# Now separate the data

A = Z[label.ravel()==0]

B = Z[label.ravel()==1]

# Plot the data

plt.scatter(A[:,0],A[:,1])

plt.scatter(B[:,0],B[:,1],c = 'r')

plt.scatter(center[:,0],center[:,1],s = 80,c = 'y', marker = 's')

plt.xlabel('Test Data'),plt.ylabel('Z samples')

plt.show()

-
Q2. In question 1 you have implemented KMEAN, where you had seen the hard clustering, you task is to
compare the hard clustering KMEAN versus Fuzzy C Mean (FCM).

FCM is most usually used techniques for image segmentation of medical image
applications because of its fuzzy nature, where one pixel can belong to multiple clusters and
which lead to better performance than crisp methods. Conventional FCM fail to perform well
enough in the presence of noise and intensity inhomogeneity in MRI images.

FCM finds its applications in variety of problems varying from data analysis to segmentation of
images. In FCM, it is possible for a data sample to belong to multiple clusters at the same time.
The similarity is indicated by the membership value. In FCM a data sample is assigned with a
membership value based on its similarity with the cluster center. The membership values are
between 0 to 1 and more the similarity, higher the membership value. FCM is a repetitive
algorithm and the solution is achieved by repetitively updating the cluster center and
membership value. These updating equations are obtained by solving the cost function. Let X =
{x1, x2, x3, . . . , xN } denotes the data with N data samples. It has to be partitioned into c-
clusters by minimizing the subsequent cost function.

The two algorithms used two different approaches, in k-means, data will be included in
one particular cluster, whereas in FCM, a data can be included in all existing clusters, but with
varying degrees of membership, in a range of values [0 1](1,2). In concept, the two algorithms
have similarities in how they work.

Fuzzy c-means clustering has can be considered a better algorithm compared to the k-
Means algorithm. Unlike the k-Means algorithm where the data points exclusively belong to
one cluster, in the case of the fuzzy c-means algorithm, the data point can belong to more
than one cluster with a likelihood.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy