I try to find out how to work with PHP-ML when i want to recommend some items to current customer.
My dataset (numeration is only the number of the row):
- Product 1 was purchased together with Product 2
- Product 1 was purchased together with Product 2
- Product 1 was purchased together with Product 3
- Product 1 was purchased together with Product 2
- Product 2 was purchased together with Product 4
- Product Y.. was purchased together with Product X..
As a customer i had bought in the past Product 1. So normally i would expect in my recommendation box product 2 because 3 people bought it together with product 1.
I think i need here some regression algorythm which give me some correlation value between product X and product Y.
I thought about the linear SVR algorythm but i have no idea how to train it?
// Step 1: Load the Dataset
// Step 2: Prepare the Dataset
// Step 3: Generate the training/testing Dataset
$samples = [[1,2], [1,2], [1,3], [1,2], [2,4], [X,Y..]];
$targets = [?, ?, ? , ? , ? , ?];
$regression = new LeastSquares();
// Step 4: Train the classifier
$regression->train($samples, $targets);
echo $regression->predict([1,2]);
In my mind i should get some value like 0.25 -> 25% percent of customers who bought product 1 also bought product 2. Then i could order my predictions and have the order in my recommendation box. My main question is, what should i use for train? Do I understand something completely wrong?
Thank you