Closed Cafelatte1 closed 2 years ago
I found that
the K parameter when initializing the tfrs.metrics.FactorizedTopK is calculated and ordered the number of top K score, which is scored by (user embedding (1) * all candidate embedding (N))
the K parameter when initializing the tf.keras.metrics.TopKCategoricalAccuracy is the threshold used for deciding whether the value is in K th.
So you can use like below codes
# K is the threshold values you wanna monitor
k_seq = [5, 10, 20, 50, 100]
tmp_metrics = [tf.keras.metrics.TopKCategoricalAccuracy(k=i, name="top_"+str(i)+"_acc") for i in k_seq]
# Specify above list when initializing tfrs.metrics.FactorizedTopK for parameter 'metrics'
# If you use TopKCategoricalAccuracy with K value that is more than K of FactorizedTopK,
# The metrics shows always accuracy=1
# Because the K of tfrs.metrics.FactorizedTopK determines the maximum number(length) of score vector which can be used for evaluating with TopKCategoricalAccuracy.
tfrs.tasks.Retrieval(
metrics=tfrs.metrics.FactorizedTopK(candidates=tmp, metrics=tmp_metrics, k=100)
)
I wannted to use the tfrs.metrics.FactorizedTopK(k=200). but like above, the output shows the result only with k=1,5,10,100 (always 4 cases). I want to see the result with k=200. (contents on the picture and codes are different, but the issue on output is same)