Frequently bought together algorithm and code



Hi, I am working for a ecommerce company and want to build an algorithm similar to what amazon has for frequently bought together items. So the need is to show the items to users based on the items they have selected or are currently browsing.
We also wanted to make this more relevant with maybe bringing in the user’s community or at least the city from which he belongs to try to give more accurate recommendation. Any help is appreciated!