在SQL中计算余弦相似度

时间:2020-06-29 17:15:14

标签: sql amazon-redshift cosine-similarity

我有一个这样的数据集(大尺寸)

   id_brand id_member
    1        100
    2        105
    1        106
    3        100

,我想计算不同品牌之间的余弦相似度。 公式如下

{\ displaystyle \ cos \ theta = {\ frac {\ mathbf {A} \ cdot \ mathbf {B}} {| \ mathbf {A} || \ mathbf {B} |}}}。

我试图在pyspark中使用,但是它很复杂,所以我想在sql(redhisft)中进行操作,但是我不知道要这样做。

谢谢

0 个答案:

没有答案
相关问题