Challenge

Unsupervised Learning - Kmeans Week 11 Challenge


1.How does similarity is calculated if data is categorical in nature
Similarity is the basic building block for techniques such as Recommendation engines, clustering, classification and
anomaly detection.

Similarity is the measure of how alike two data objects are. Similarity in the data mining context is usually described as
a distance with dimensions representing features of the objects. If this distance is small, there will be high degree of
similarity; if this distance is large, there will be low degree of similarity. Similarity is subjective and is highly
dependent on the domain and application. For example, two fruits can be similar because of their color, size or taste.
Care should be taken when calculating distance across dimensions/features that are unrelated. The relative values of each
feature must be normalized, or one feature could end up dominating the distance calculation. Similarity is measured in the
range 0 to 1 [0,1].

Example: Similarity = 1 if X = Y (Where X, Y are two objects)
Similarity = 0 if X ≠ Y

Types of calculating similarity for categorical data:
*Euclidean distance is the most commonly-used of our distance measures. Because of this, Eucledian distance is often just
referred to as “distance”. When data is dense or continuous, this is the best proximity measure. The Euclidean distance
between two points is the length of the path connecting them. This distance between two points is given by the Pythagorean
theorem.

*Manhattan distance is a metric in which the distance between two points is the sum of the absolute differences of their
Cartesian coordinates. In simple language, it is the absolute sum of the difference between the x-coordinates and
y-coordinates of each of the points. Suppose we have a point A and a point B. To find the manhattan distance between them, we just have to sum up the absolute variation along the x and y axes. We find manhattan distance between two points by measuring along axis at right angles.
In a plane with p1 at (x1, y1) and p2 at (x2, y2).
Manhattan distance = |x1 – x2| + |y1 – y2|
This Manhattan distance metric is also known as Manhattan length, rectilinear distance, L1 distance, L1 norm ,city block
distance, Minkowski’s L1 distance, taxi cab metric, or city block distance.

*Cosine similarity metric finds the normalized dot product of the two attributes. By determining the cosine similarity, we
will effectively try to find the cosine of the angle between the two objects. The cosine of 0° is 1, and it is less than
1 for any other angle. It is thus a judgement of orientation and not magnitude: two vectors with the same orientation have
a cosine similarity of 1, two vectors at 90° have a similarity of 0, and two vectors diametrically opposed have a
similarity of -1, independent of their magnitude. Cosine similarity is particularly used in positive space, where the
outcome is neatly bounded in [0,1]. One of the reasons for the popularity of cosine similarity is that it is very
efficient to evaluate, especially for sparse vectors.

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.