Challenge

Unsupervised Learning - Kmeans Week 11 Challenge

Q.1 How does similarity is calculated if data is categorical in nature.

  • Measuring similarity or distance between two data points is a core requirement for several data mining and knowledge discovery tasks that involve distance computation. Examples include clustering (kmeans), distance-based outlier detection, classification (knn, SVM), and several other data mining tasks.
  • For continuous data sets, the Minkowski Distance is a general method used to compute distance between two multivariate points. In particular, the Minkowski Distance of order 1 (Manhattan) and order 2 (Euclidean)
    are the two most widely used distance measures for continuous data.
  • The notion of similarity or distance for categorical data is not as straightforward as for continuous data.
    The key characteristic of categorical data is that the different values that a categorical attribute takes are
    not inherently ordered.Thus, it is not possible to directly compare two different categorical values.
  • The simplest way to find similarity between two categorical attributes is to assign a similarity of 1 if the values are identical and a similarity of 0 if the values are not identical.
  • Following are the some Similarity measures used to find the distance between two or more objects or entities containing categorical data.
  • Similarity measures such as Eskin, IOF, OF, Overlap (Simple Matching), Goodall1, Goodall2, Goodall3, Goodall4, Lin, Lin1, Morlini_Zani (S2), Variable Entropy and Variable Mutability.
  • Simple matching and jaccard Coefficients.
  • For example:
  • For binary variables
  • Simple matching and jaccard Coefficients

  • As we know Manhattan and Euclidean are used to mesaure the similarity of numerical or contineous data.But categorical variables we use Hamming distance.
  • Hamming distance:
  • Hamming Distance measures the similarity between two strings of the same length. The Hamming Distance between two strings of the same length is the number of positions at which the corresponding characters are different.
  • Let’s understand the concept using an example. Let’s say we have two strings:
  • “euclidean” and “manhattan”
  • Since the length of these strings is equal, we can calculate the Hamming Distance.
  • We will go character by character and match the strings. The first character of both the strings (e and m respectively) is different. Similarly, the second character of both the strings (u and a) is different. and so on.
  • Look carefully – seven characters are different whereas two characters (the last two characters) are similar:
  • Hence, the Hamming Distance here will be 7. Note that larger the Hamming Distance between two strings, more dissimilar will be those strings (and vice versa).

Q.2 Implement K-means for “Car dataset” and come up with the business insights.

Solution of this question is uploaded in .ipynb format

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.