PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.
Slopeone Package requires PHP 7.4 or higher.
INFO: If you are using an older version of php this package may not function correctly.
The supported way of installing Slopeone
package is via Composer.
composer require phpjuice/slopeone
Slopeone Package is designed to be very simple and straightforward to use. All you have to do is to load rating data, then predict future ratings based on the training set provided.
The Slopeone
object is created by direct instantiation:
use PHPJuice\Slopeone\Algorithm;
// Create an instance
$slopeone = new Algorithm();
Adding Rating values can be easily done by providing an array of users ratings via the update() method:
$data =[
[
"squid" => 1,
"cuttlefish" => 0.5,
"octopus" => 0.2
],
[
"squid" => 1,
"octopus" => 0.5,
"nautilus" => 0.2
],
[
"squid" => 0.2,
"octopus" => 1,
"cuttlefish" => 0.4,
"nautilus" => 0.4
],
[
"cuttlefish" => 0.9,
"octopus" => 0.4,
"nautilus" => 0.5
]
];
$slopeone->update($data);
all you have to do to predict ratings for a new user is to run the slopeone::predict method
$results = $slopeone->predict([
"squid" => 0.4
]);
this should produce the following results
[
"cuttlefish"=>0.25,
"octopus"=>0.23333333333333,
"nautilus"=>0.1
];
you can easily run tests using composer
composer test
- PHP - The programing language used
- Composer - Dependency Management
- Pest - An elegant PHP Testing Framework
Please see the changelog for more information on what has changed recently.
Please see CONTRIBUTING.md for details and a todo list.
If you discover any security related issues, please email author instead of using the issue tracker.
We use SemVer for versioning. For the versions available, see the tags on this repository.
license. Please see the Licence for more information.