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:

*

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


*How can we modify the algorithm to specify weights?


*Any other algorithms that would be appropriate for this problem?


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

Use encoding, one simple way of doing encoding is one-hot encoding and there are other encoding methods exists.

How can we modify the algorithm to specify weights?

If you want to use weights on different features, you can consider Euclidean distance

Any other algorithms that would be appropriate for this problem?

Really depends on the problem. Essentially we need to answer what is similar? similar in terms of what? May be resell value? F
or example, if two properties are in different communities, one is big in size, but poor in neighborhood safety, another one is small in size, but have very nice community. Both of them have exact resell value, do you consider them similar?
