I have a list of orders, which contains a list of items.

I need to use machine learning to suggest other items to customers based purely on their basket at the time of checkout, considering the history of orders placed.

Ideally it must be done with ML.NET.

I have tried a few variations of matrix factorisation but to predict more items for a customer, the starting basket must be in the training set. I can't retrain every time a order is placed, that would take a long time.

Am I going about this the wrong way? Are there different techniques that would work better or have I missed something from matrix factorisation?

Many thanks

  • $\begingroup$ Related: learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/… $\endgroup$
    – Memristor
    Commented Aug 1, 2023 at 9:01
  • $\begingroup$ I had tried that, but unfortunately the predict function input is an existing user with some ratings already, which were contained in the training set. I need to predict with an input which was not in the training set. $\endgroup$
    – Josh Hales
    Commented Aug 1, 2023 at 9:07
  • $\begingroup$ For predicting something that is not in the training set you need some of the features of it to be in the training set, e.g. a content recommender system. Check my answer to this post. $\endgroup$
    – Memristor
    Commented Aug 1, 2023 at 9:11

1 Answer 1


Let's say a user have a past basket such item1, item2, item3. Your train set should have the following (X, Y) subsets, being Y a predicted subset:

  • X=(item1), Y=(item2, item3)
  • X=(item2), Y=(item1, item3)
  • X=(item3), Y=(item1, item2)
  • X=(item1, item2), Y=(item3)
  • X=(item2, item3), Y=(item1)
  • X=(item1, item3), Y=(item2)

have you done this? With this technique you should not need to retrain that many often. Also for recommender systems it is always better to have at least a content recommender and a "popular/frequent" recommender, than make an hybrid one with the two previous.

  • $\begingroup$ Not really what I'm looking for. I need to train on a set of data then consume the model in the future. I'm sure I'll retrain in the future but it can't really be a regular thing. $\endgroup$
    – Josh Hales
    Commented Aug 1, 2023 at 10:09
  • $\begingroup$ Sorry @JayHales but your comment has nothing to do with my answer. You can retrain a model done as I propose, splitting data as I suggest has nothing to do with the ability of retraining it on the future. $\endgroup$
    – Memristor
    Commented Aug 1, 2023 at 13:18
  • $\begingroup$ Okay, I think I understand your point now. But I don't think ML.NET supports using arrays for input data in this way? $\endgroup$
    – Josh Hales
    Commented Aug 1, 2023 at 14:33
  • $\begingroup$ Sadly @JayHales I can't help you on this because I never used ML.net. $\endgroup$
    – Memristor
    Commented Aug 1, 2023 at 15:12
  • $\begingroup$ What library could this be implemented in? $\endgroup$
    – Josh Hales
    Commented Aug 1, 2023 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.