Skip to main content
edited title
Link
Roger V.
  • 4.5k
  • 15
  • 35

cosine Cosine similarity with weights

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
kms
  • 570
  • 3
  • 24

cosine similarity with weights

We're doing pairwise similarity computation for some real estate properties. Our data goes something like this:

import pandas as pd
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity

df = pd.DataFrame({
                           'Square Footage': np.random.randint(500, 600, 4),
                           'Year Renovated': np.random.randint(1992, 2019, 4),
                           'Year Built': [1990, 2000, 1995, 2005],
                           'Rent': [1000, 800, 1200, 1500],
                           'ameneties': [4, 6, 8, 10]

                  })

User enters similar information about the a property of interest and then we do cosine similarity between the two vectors.

My questions are:

  1. How do we use data other than numbers such as text data and other categorical variables to compute similarity?

  2. How can we modify the algorithm to specify weights?

  3. Any other algorithms that would be appropriate for this problem?