PHPackages                             phpjuice/slopeone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpjuice/slopeone

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpjuice/slopeone
=================

PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.

v2.0.1(4y ago)858.7k↓75%8MITPHPPHP ^7.4|^8.0|^8.1

Since Jun 12Pushed 4y ago4 watchersCompare

[ Source](https://github.com/phpjuice/slopeone)[ Packagist](https://packagist.org/packages/phpjuice/slopeone)[ RSS](/packages/phpjuice-slopeone/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

Slopeone
========

[](#slopeone)

[![Tests](https://github.com/phpjuice/slopeone/workflows/Tests/badge.svg?branch=main)](https://github.com/phpjuice/slopeone/workflows/Tests/badge.svg?branch=main)[![Maintainability](https://camo.githubusercontent.com/80bcc2fe542434a0a51ce37787490f21416f0be25b81a6e8e58aaa6a5de80f13/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f34623336323438316165386138636633393933362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/phpjuice/slopeone/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/abff3b19e46ff313ea86c7020c2f80d0ce1eca08eba66df2adaa75360fc13532/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f76)](https://packagist.org/packages/phpjuice/slopeone)[![Total Downloads](https://camo.githubusercontent.com/8df01835ee03ed24ed08767fe11148225c336a097bb21c4d723cb7f71ea274e6/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f646f776e6c6f616473)](https://packagist.org/packages/phpjuice/slopeone)[![License](https://camo.githubusercontent.com/e4bb640b192d7d4617e7208c052c1494ec661b2a3ec48371c24da37e5351bdd3/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f6c6963656e7365)](https://packagist.org/packages/phpjuice/slopeone)

PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.

Installation
------------

[](#installation)

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
```

Usage
-----

[](#usage)

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.

### Loading files

[](#loading-files)

The `Slopeone` object is created by direct instantiation:

```
use PHPJuice\Slopeone\Algorithm;

// Create an instance
$slopeone = new Algorithm();
```

### Adding Rating values

[](#adding-rating-values)

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);
```

### Predicting ratings

[](#predicting-ratings)

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
];
```

Running the tests
-----------------

[](#running-the-tests)

you can easily run tests using composer

```
composer test
```

Built With
----------

[](#built-with)

- [PHP](http://www.php.net) - The programing language used
- [Composer](https://getcomposer.org) - Dependency Management
- [Pest](https://pestphp.com) - An elegant PHP Testing Framework

Changelog
---------

[](#changelog)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details and a todo list.

Security
--------

[](#security)

If you discover any security related issues, please email author instead of using the issue tracker.

Credits
-------

[](#credits)

- [Daniel Lemire](https://github.com/lemire)
- [SlopeOne Predictors for Online Rating-Based Collaborative Filtering](https://www.researchgate.net/publication/1960789_Slope_One_Predictors_for_Online_Rating-Based_Collaborative_Filtering)

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/PHPJuice/slopeone/tags).

License
-------

[](#license)

license. Please see the [Licence](https://github.com/phpjuice/slopeone/blob/main/LICENSE) for more information.

[![Tests](https://github.com/phpjuice/slopeone/workflows/Tests/badge.svg?branch=main)](https://github.com/phpjuice/slopeone/workflows/Tests/badge.svg?branch=main)[![Maintainability](https://camo.githubusercontent.com/80bcc2fe542434a0a51ce37787490f21416f0be25b81a6e8e58aaa6a5de80f13/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f34623336323438316165386138636633393933362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/phpjuice/slopeone/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/abff3b19e46ff313ea86c7020c2f80d0ce1eca08eba66df2adaa75360fc13532/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f76)](https://packagist.org/packages/phpjuice/slopeone)[![Total Downloads](https://camo.githubusercontent.com/8df01835ee03ed24ed08767fe11148225c336a097bb21c4d723cb7f71ea274e6/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f646f776e6c6f616473)](https://packagist.org/packages/phpjuice/slopeone)[![License](https://camo.githubusercontent.com/e4bb640b192d7d4617e7208c052c1494ec661b2a3ec48371c24da37e5351bdd3/687474703a2f2f706f7365722e707567782e6f72672f7068706a756963652f736c6f70656f6e652f6c6963656e7365)](https://packagist.org/packages/phpjuice/slopeone)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~208 days

Total

4

Last Release

1538d ago

Major Versions

v1.x-dev → v2.0.02021-11-06

PHP version history (3 changes)v1.0.0PHP &gt;=7.2

v2.0.0PHP ^7.4|^8.0

v2.0.1PHP ^7.4|^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/071fef576e19ad7fd90ce1f76ea74521225728cb9fd97c2fc48a1e9a41978f65?d=identicon)[mhdcodes](/maintainers/mhdcodes)

---

Top Contributors

[![mhdcodes](https://avatars.githubusercontent.com/u/9967336?v=4)](https://github.com/mhdcodes "mhdcodes (8 commits)")

---

Tags

algorithmcollaborative-filteringrecommender-systemslopeonerecommendationrecommendercollaborative filteringweighted slope one

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpjuice-slopeone/health.svg)

```
[![Health](https://phpackages.com/badges/phpjuice-slopeone/health.svg)](https://phpackages.com/packages/phpjuice-slopeone)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[phpjuice/opencf

PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.

975.3k](/packages/phpjuice-opencf)[tigo/recommendation

collaborative filtering recommender systems

859.4k](/packages/tigo-recommendation)[oveleon/contao-recommendation-bundle

Recommendation integration for Contao Open Source CMS

107.1k2](/packages/oveleon-contao-recommendation-bundle)[recolize/module-recommendation-engine-magento2

The Recolize Recommendation Engine Extension for Magento 2

115.0k](/packages/recolize-module-recommendation-engine-magento2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
