Kotlin implementation of the Slope One collaborative filtering algorithm.
The Application comes with a built-in web server based on Spark.
Java 7+
An executable JAR can be built by running the shadowJar Gradle task, either from your IDE or command line:
$ ./gradlew shadowJar
Once the JAR has been built, the app is started using:
$ java -jar build/libs/slopeone-1.1-SNAPSHOT-all.jar
The web server will be running on http://localhost:4567
The web service provides the following API:
Used to test if the application is running.
Request:
GET /status
Response:
"OK"
Clears the rating data.
Request:
GET /clear
Response:
"Data cleared."
Adds rating data.
Request:
PUT /ratings
Content-Type: application/json
Payload:
{
"entries": [
{
"item1": 1,
"item2": 0.5,
"item3": 0.2
},
{
"item1": 1,
"item3": 0.5,
"item4": 0.2
},
{
"item1": 0.2,
"item2": 0.4,
"item3": 1,
"item4": 0.4
},
{
"item2": 0.9,
"item3": 0.4,
"item4": 0.5
}
]
}
Response:
"Ratings added."
Returns the predictions based on provided ratings.
Request:
POST /predict
Content-Type: application/json
Payload:
{
"entries":
{
"item1": 0.4
}
}
Response:
{
"predictions": {
"item2": 0.25,
"item3": 0.23,
"item4": 0.1
}
}
Combines /ratings and /predict into a single request. Uses a separate instance of the engine to avoid interfering with other requests.
Request:
POST /predict-with-ratings
Content-Type: application/json
Payload:
{
"ratings": {
"entries": [
{
"item1": 1,
"item2": 0.5,
"item3": 0.2
},
{
"item1": 1,
"item3": 0.5,
"item4": 0.2
},
{
"item1": 0.2,
"item2": 0.4,
"item3": 1,
"item4": 0.4
},
{
"item2": 0.9,
"item3": 0.4,
"item4": 0.5
}
]
},
"predict": {
"entries":
{
"item1": 0.4
}
}
}
Response:
{
"predictions": {
"item2": 0.25,
"item3": 0.23,
"item4": 0.1
}
}