예제 #1
0
            protected ItemItemSimilarity computeNext()
            {
                int size = itemIDs.Length;
                ItemItemSimilarity result = null;

                while (result == null && i < size - 1)
                {
                    long   itemID2 = itemIDs[j];
                    double similarity;
                    try {
                        similarity = otherSimilarity.ItemSimilarity(itemID1, itemID2);
                    } catch (TasteException te) {
                        // ugly:
                        throw new InvalidOperationException(te.Message, te);
                    }
                    if (!Double.IsNaN(similarity))
                    {
                        result = new ItemItemSimilarity(itemID1, itemID2, similarity);
                    }
                    if (++j == size)
                    {
                        itemID1 = itemIDs[++i];
                        j       = i + 1;
                    }
                }
                return(result);
            }
예제 #2
0
            public double Estimate(long itemID)
            {
                Tuple <long, long> pair = new Tuple <long, long>(toItemID, itemID);

                if (rescorer != null && rescorer.IsFiltered(pair))
                {
                    return(Double.NaN);
                }
                double originalEstimate = similarity.ItemSimilarity(toItemID, itemID);

                return(rescorer == null ? originalEstimate : rescorer.Rescore(pair, originalEstimate));
            }
 public Double Get(Tuple <long, long> key)
 {
     return(similarity.ItemSimilarity(key.Item1, key.Item2));
 }