item match. * * This function calculates how much a user likes a certain item (product, movie etc.) * * $user and $item can also be Vectors resulting in a individual evaluation * e.g. the user matrix contains a user in every row, every column represents a score for a certain attribute * the item matrix contains in every row a score for how much it belongs to a certain attribute. Each column represents an item. * example: users columns define how much a user likes a certain movie genre and the item rows define how much this movie belongs to a certain genre. * the multiplication gives a score of how much the user may like that movie. * A significant amount of attributes are required to calculate a good match * * @param array> $users A mxa matrix where each "m" defines how much the user likes a certain attribute type and "a" defines different users * @param array> $items A bxm matrix where each "b" defines a item and "m" defines how much it belongs to a certain attribute type * * @return array * * @since 1.0.0 */ public static function score(array $users, array $items) : array { $matrix = []; foreach ($users as $uid => $userrow) { foreach ($items as $iid => $itemrow) { $matrix[$uid][$iid] = 0.0; $userrow = \array_values($userrow); $itemrow = \array_values($itemrow); foreach ($userrow as $idx => $user) { $matrix[$uid][$iid] += $user * $itemrow[$idx]; } } } return $matrix; } }