-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIntegrationTest.php
executable file
·46 lines (40 loc) · 1.02 KB
/
IntegrationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use OpenCF\RecommenderService;
it('tests predictions with real data', function () {
$dataset = transpose([
"user1" => [
"squid" => 1,
"cuttlefish" => 0.5,
"octopus" => 0.2,
],
"user2" => [
"squid" => 1,
"octopus" => 0.5,
"nautilus" => 0.2,
],
"user3" => [
"squid" => 0.2,
"octopus" => 1,
"cuttlefish" => 0.4,
"nautilus" => 0.4,
],
"user4" => [
"cuttlefish" => 0.9,
"octopus" => 0.4,
"nautilus" => 0.5,
],
]);
// Create an instance
$recommenderService = new RecommenderService($dataset);
// Get a recommender
$recommender = $recommenderService->weightedSlopeone();
// Predict future ratings
$results = $recommender->predict([
'squid' => 0.4,
]);
expect($results)->toBe([
"cuttlefish" => 0.25,
"octopus" => 0.23,
"nautilus" => 0.1,
]);
});