在 spark 中使用 LSH 对数据帧中的每个点进行 运行 最近邻查询
Using LSH in spark to run nearest neighbors query on every point in dataframe
对于数据帧中的每个特征向量,我需要 k 个最近的邻居。我正在使用来自 pyspark 的 BucketedRandomProjectionLSHModel。
创建模型的代码
brp = BucketedRandomProjectionLSH(inputCol="features", outputCol="hashes",seed=12345, bucketLength=n)
model = brp.fit(data_df)
df_lsh = model.transform(data_df)
现在,我如何 运行 对 data_df 中的每个点进行近似最近邻查询。
我试过广播模型但出现 pickle 错误。
此外,定义一个 udf 来访问模型会给出错误 Method __getstate__([]) does not exist
使用应该使用.approxSimilarityJoin
model.df_lsh(df_lsh, df_lsh)
对于数据帧中的每个特征向量,我需要 k 个最近的邻居。我正在使用来自 pyspark 的 BucketedRandomProjectionLSHModel。
创建模型的代码
brp = BucketedRandomProjectionLSH(inputCol="features", outputCol="hashes",seed=12345, bucketLength=n)
model = brp.fit(data_df)
df_lsh = model.transform(data_df)
现在,我如何 运行 对 data_df 中的每个点进行近似最近邻查询。
我试过广播模型但出现 pickle 错误。
此外,定义一个 udf 来访问模型会给出错误 Method __getstate__([]) does not exist
使用应该使用.approxSimilarityJoin
model.df_lsh(df_lsh, df_lsh)