Implementing a recursive algorithm in pyspark to find pairings within a dataframe

后端 未结 2 1107
长发绾君心
长发绾君心 2021-02-06 09:32

I have a spark dataframe (prof_student_df) that lists student/professor pair for a timestamp. There are 4 professors and 4 students for each timestamp and each prof

2条回答
  •  故里飘歌
    2021-02-06 10:02

    As our friend @cronoik mention you need to use Hungarian algorithm, the best code I saw for unbalance assignment problem in python is: https://github.com/mayorx/hungarian-algorithm (also have some example in the repository :) )

    you just need to convert your DataFrame into Numpy array and pass to the KM_Matcher then add a column with withColumn function in spark depend on your answer from KM_Matcher.

提交回复
热议问题