Please be patient with my writing, as my English is not proficient.
As a programmer, I wanna learn about the algorithm, or the machine learning intelligence, that are im
A first attempt could look like this:
//First Calculate how often any product pair was bought together
//The time/memory should be about Sum over all Customers of Customer.BoughtProducts^2
Dictionary> boughtTogether=new Dictionary>();
foreach(Customer in Customers)
{
foreach(product1 in Customer.BoughtProducts)
foreach(product2 in Customer.BoughtProducts)
{
int counter=boughtTogether[Pair(product1,product2)] or 0 if missing;
counter++;
boughtTogether[Pair(product1,product2)]=counter;
}
}
boughtTogether.GroupBy(entry.Key.First).Select(group.OrderByDescending(entry=>entry.Value).Take(10).Select(new{key.Second as ProductID,Value as Count}));
First I calculate how often each pair of products was bought together, and then I group them by the product and select the top 20 other products bought with it. The result should be put into some kind of dictionary keyed by product ID.
This might get too slow or cost too much memory for large databases.