Lazy loaded image
Mathematics
Lazy loaded imageWeighted Euclidean Distance
Words 179Read Time 1 min
Jul 2, 2021
Apr 22, 2025
type
Post
status
Published
date
Jul 2, 2021
slug
summary
tags
Mathematics
category
Mathematics
icon
password

Calculating Product Similarity Using Weighted Euclidean Distance

Suppose we have two products, Product A and Product B, and each has the following features:
Feature Type
Feature Name
Product A
Product B
Weight (wᵢ)
Image Feature
Image Vector
0.5
0.7
0.4
Text Feature
Title Vector
0.8
0.6
0.3
Categorical
Brand (One-hot)
1.0
0.0
0.2
Categorical
Color (One-hot)
1.0
1.0
0.1

✅ Step-by-Step Calculation

We'll use the formula:

1. Image Feature:

2. Title/Text Feature:

3. Brand (One-hot):

4. Color (One-hot):


Final Distance:


Interpretation:

  • The smaller the distance, the more similar the products are.
  • In this example, the brand difference contributed the most to the distance due to its high weight and binary difference.
  • The image and text also influenced similarity moderately.
  • Color was identical, so it had no effect on the distance.
上一篇
SQL Q&A4 The JOIN operation
下一篇
Cosine Similarity