Open artsnr1 opened 4 years ago
Currently it gives me all possible itemsets. What I want is a function that accepts an item and returns all its pairs (excluding itself) sorted in order of support getRelatedItems(item, maxItems?)
var transactions = [ [1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5], [1, 2, 3, 5] ]; getRelatedItems(1) // Output: [3, 5, 2] getRelatedItems(2) // Output: [5, 3, 1] getRelatedItems(3) // Output: [5, 2, 1] getRelatedItems(4) // Output: [] getRelatedItems(5) // Output: [2, 3, 1]
Currently it gives me all possible itemsets. What I want is a function that accepts an item and returns all its pairs (excluding itself) sorted in order of support getRelatedItems(item, maxItems?)
var transactions = [ [1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5], [1, 2, 3, 5] ]; getRelatedItems(1) // Output: [3, 5, 2] getRelatedItems(2) // Output: [5, 3, 1] getRelatedItems(3) // Output: [5, 2, 1] getRelatedItems(4) // Output: [] getRelatedItems(5) // Output: [2, 3, 1]