docs/algo/sona/swing.md
Swing是一个利用用户行为计算item与item之间的相似度的算法,通常用于推荐召回。其基本原理是,如果两个用户的共同关联item越少,则这些item之间的相似度越高,具体计算公式见下图。其中,其中Ui表示购买了item_i的用户集合,Uj表示购买了item_j的用户集合,Iu表示用户u购买的item集合,Iv表示用户V购买的item集合。gamma通常的取值范围为[-1, 0],beta和gamma参数是对两条购买记录长度的惩罚。
userId itemId,得到的是item之间的相似度itemId itemId scoretab, 空格等DISK_ONLY/MEMORY_ONLY/MEMORY_AND_DISKinput=hdfs://my-hdfs/data
output=hdfs://my-hdfs/output
source ./spark-on-angel-env.sh
$SPARK_HOME/bin/spark-submit \
--master yarn-cluster\
--conf spark.ps.instances=1 \
--conf spark.ps.cores=1 \
--conf spark.ps.jars=$SONA_ANGEL_JARS \
--conf spark.ps.memory=10g \
--name "swing angel" \
--jars $SONA_SPARK_JARS \
--driver-memory 5g \
--num-executors 1 \
--executor-cores 4 \
--executor-memory 10g \
--class org.apache.spark.angel.examples.graph.SwingExample \
../lib/spark-on-angel-examples-3.3.0.jar
input:$input output:$output sep:tab storageLevel:MEMORY_ONLY useBalancePartition:true \
partitionNum:4 psPartitionNum:1