Skip to content

Commit b7f01b8

Browse files
committed
add README.md file
1 parent 5633a1e commit b7f01b8

File tree

14 files changed

+2105
-300
lines changed

14 files changed

+2105
-300
lines changed

.editorconfig

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# This file is for unifying the coding style for different editors and IDEs
2-
# editorconfig.org
3-
41
root = true
52

63
[*]
7-
end_of_line = lf
84
charset = utf-8
9-
trim_trailing_whitespace = true
10-
insert_final_newline = false
5+
end_of_line = lf
6+
insert_final_newline = true
117
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
1215
indent_size = 2

.gitignore

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,62 @@
1-
2-
# Created by https://www.gitignore.io/api/linux,windows,composer,visualstudiocode
3-
4-
### Composer ###
5-
composer.phar
6-
composer.lock
7-
/vendor/
8-
9-
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
10-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
11-
# composer.lock
12-
13-
### Linux ###
14-
*~
15-
16-
# temporary files which can be created if a process still has a handle open of a deleted file
17-
.fuse_hidden*
18-
19-
# KDE directory preferences
20-
.directory
21-
22-
# Linux trash folder which might appear on any partition or disk
23-
.Trash-*
24-
25-
# .nfs files are created when an open file is removed but is still being accessed
26-
.nfs*
27-
28-
### VisualStudioCode ###
29-
.vscode/*
30-
!.vscode/settings.json
31-
!.vscode/tasks.json
32-
!.vscode/launch.json
33-
!.vscode/extensions.json
34-
.history
35-
36-
### Windows ###
37-
# Windows thumbnail cache files
38-
Thumbs.db
39-
ehthumbs.db
40-
ehthumbs_vista.db
41-
42-
# Folder config file
43-
Desktop.ini
44-
45-
# Recycle Bin used on file shares
46-
$RECYCLE.BIN/
47-
48-
# Windows Installer files
49-
*.cab
50-
*.msi
51-
*.msm
52-
*.msp
53-
54-
# Windows shortcuts
55-
*.lnk
56-
57-
# End of https://www.gitignore.io/api/linux,windows,composer,visualstudiocode
1+
2+
# Created by https://www.gitignore.io/api/linux,windows,composer,visualstudiocode
3+
4+
### Composer ###
5+
composer.phar
6+
/vendor/
7+
8+
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
9+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
10+
# composer.lock
11+
12+
### Linux ###
13+
*~
14+
15+
# temporary files which can be created if a process still has a handle open of a deleted file
16+
.fuse_hidden*
17+
18+
# KDE directory preferences
19+
.directory
20+
21+
# Linux trash folder which might appear on any partition or disk
22+
.Trash-*
23+
24+
# .nfs files are created when an open file is removed but is still being accessed
25+
.nfs*
26+
27+
### VisualStudioCode ###
28+
.vscode/*
29+
!.vscode/settings.json
30+
!.vscode/tasks.json
31+
!.vscode/launch.json
32+
!.vscode/extensions.json
33+
.history
34+
35+
### Windows ###
36+
# Windows thumbnail cache files
37+
Thumbs.db
38+
ehthumbs.db
39+
ehthumbs_vista.db
40+
41+
# Folder config file
42+
Desktop.ini
43+
44+
# Recycle Bin used on file shares
45+
$RECYCLE.BIN/
46+
47+
# Windows Installer files
48+
*.cab
49+
*.msi
50+
*.msm
51+
*.msp
52+
53+
# Windows shortcuts
54+
*.lnk
55+
56+
57+
.phpintel/
58+
# End of https://www.gitignore.io/api/linux,windows,composer,visualstudiocode
59+
60+
.env
61+
.phpunit.result.cache
62+
.php_cs.cache

.php_cs.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

100644100755
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
language: php
22
php:
3-
- '5.6'
4-
- '7.0'
5-
- '7.1'
6-
- '7.2'
3+
- "7.2"
74

85
cache:
96
directories:
107
- $HOME/.composer/cache
118

129
before_script:
13-
- composer install
10+
- composer install
1411
script: composer test

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Slopeone
2+
3+
PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.
4+
5+
[![Latest Stable Version](https://poser.pugx.org/phpjuice/slopeone/v/stable)](https://github.com/PHPJuice/slopeone/releases/latest)
6+
[![Total Downloads](https://poser.pugx.org/phpjuice/slopeone/downloads)](https://packagist.org/packages/phpjuice/slopeone)
7+
[![Build Status](https://travis-ci.org/PHPJuice/slopeone.svg?branch=master)](https://travis-ci.org/PHPJuice/slopeone)
8+
[![GitHub issues](https://img.shields.io/github/issues/PHPJuice/slopeone.svg)](https://github.com/PHPJuice/slopeone/issues)
9+
[![License](https://poser.pugx.org/phpjuice/slopeone/license)](https://github.com/PHPJuice/slopeone/blob/master/LICENSE)
10+
11+
## Requirements
12+
13+
Slopeone Package requires PHP 5.6+
14+
15+
> **WARNING:** This library may not function correctly on PHP < 5.6.
16+
17+
## Getting Started
18+
19+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
20+
21+
### Installing
22+
23+
The supported way of installing the Slopeone Package is via Composer.
24+
25+
```sh
26+
$ composer require phpjuice/slopeone
27+
```
28+
29+
## Usage
30+
31+
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
32+
33+
### Loading files
34+
35+
The `Slopeone` object is created by direct instantiation:
36+
37+
```php
38+
use PHPJuice\Slopeone\Algorithm;
39+
40+
// Create an instance
41+
$slopeone = new Algorithm();
42+
43+
```
44+
45+
### Adding Rating values
46+
47+
Adding Rating values can be easly done by providing an array of users ratings via the update() method:
48+
49+
```php
50+
51+
$data =[
52+
[
53+
"squid" => 1,
54+
"cuttlefish" => 0.5,
55+
"octopus" => 0.2
56+
],
57+
[
58+
"squid" => 1,
59+
"octopus" => 0.5,
60+
"nautilus" => 0.2
61+
],
62+
[
63+
"squid" => 0.2,
64+
"octopus" => 1,
65+
"cuttlefish" => 0.4,
66+
"nautilus" => 0.4
67+
],
68+
[
69+
"cuttlefish" => 0.9,
70+
"octopus" => 0.4,
71+
"nautilus" => 0.5
72+
]
73+
];
74+
75+
$slopeone->update($data);
76+
77+
```
78+
79+
### Predicting ratings
80+
81+
all you have to do to predict ratings for a new user is to run the slopeone::predict method
82+
83+
```php
84+
$results = $slopeone->predict([
85+
"squid" => 0.4
86+
]);
87+
```
88+
89+
this should produce the following results
90+
91+
```php
92+
[
93+
"cuttlefish"=>0.25,
94+
"octopus"=>0.23333333333333,
95+
"nautilus"=>0.1
96+
];
97+
```
98+
99+
## Running the tests
100+
101+
you can easly run tests using composer
102+
103+
```bash
104+
$ composer test
105+
```
106+
107+
## Built With
108+
109+
- [PHP](http://www.php.net) - The programing language used
110+
- [Composer](https://getcomposer.org) - Dependency Management
111+
112+
## Contributing
113+
114+
Please read [CONTRIBUTING](CONTRIBUTING.md) for details.
115+
116+
## Versioning
117+
118+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/PHPJuice/slopeone/tags).
119+
120+
## Authors
121+
122+
- [ElHaouari Mohammed](https://github.com/elhaouari-mohammed)
123+
124+
See also the list of [contributors](https://gitlab.com/opencf/opencf/graphs/master) who participated in this project.
125+
126+
## License
127+
128+
This project is licensed under the MIT License - see the [LICENSE.md](./LICENSE) file for details

SECURITY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 1.0.x | :white_check_mark: |
8+
9+
## Reporting a Vulnerability

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
theme: jekyll-theme-cayman
1+
theme: jekyll-theme-cayman

composer.json

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
11
{
2-
"name": "phpjuice/slopeone",
3-
"type": "library",
4-
"description": "PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.",
5-
"keywords": ["recommendation","recommender","collaborative filtering","weighted slope one"],
6-
"license": "MIT",
7-
"authors": [
8-
{
9-
"name": "EL-Haouari Mohammed",
10-
"email": "[email protected]"
11-
}
12-
],
13-
"support": {
14-
"issues": "https://github.com/PHPJuice/slopeone/issues",
15-
"source": "https://github.com/PHPJuice/slopeone"
16-
},
17-
"require": {
18-
"php": ">=5.6"
19-
},
20-
"autoload": {
21-
"psr-4": { "PHPJuice\\Slopeone\\": "src" }
22-
},
23-
"autoload-dev": {
24-
"psr-4": { "PHPJuice\\Slopeone\\Tests\\": "test" }
25-
},
26-
"scripts": {
27-
"test": "./vendor/bin/phpunit",
28-
"fix-coding-style": "PHP_CS_FIXER_IGNORE_ENV=1 $(PHP_BIN) vendor/bin/php-cs-fixer --diff -v fix"
29-
},
30-
"minimum-stability": "stable",
31-
"require-dev": {
32-
"phpunit/phpunit": "^5.7 || ^6.5",
33-
"friendsofphp/php-cs-fixer": "^2.3"
34-
}
2+
"name": "phpjuice/slopeone",
3+
"type": "library",
4+
"description": "PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.",
5+
"keywords": [
6+
"recommendation",
7+
"recommender",
8+
"collaborative filtering",
9+
"weighted slope one"
10+
],
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "ELHaouari Mohammed",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"support": {
19+
"issues": "https://github.com/PHPJuice/slopeone/issues",
20+
"source": "https://github.com/PHPJuice/slopeone"
21+
},
22+
"require": {
23+
"php": ">=7.2"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"PHPJuice\\Slopeone\\": "src"
28+
}
29+
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"PHPJuice\\Slopeone\\Tests\\": "test"
33+
}
34+
},
35+
"scripts": {
36+
"test": "./vendor/bin/phpunit --colors=always --configuration phpunit.xml.dist",
37+
"fix-cs": [
38+
"php-cs-fixer fix src --rules=@Symfony,@PSR2",
39+
"php-cs-fixer fix tests --rules=@Symfony,@PSR2"
40+
],
41+
"analyse": "vendor/bin/phpstan analyse src tests"
42+
},
43+
"minimum-stability": "stable",
44+
"require-dev": {
45+
"phpunit/phpunit": "^5.7 || ^6.5",
46+
"phpstan/phpstan": "^0.12.28",
47+
"squizlabs/php_codesniffer": "*"
48+
}
3549
}

0 commit comments

Comments
 (0)