Everything should be made as simple as possible, but not simpler. (Albert Einstein)

Thursday, September 3, 2015

Demo of Recommender System with LensKit and Intellij Idea

Requirements: 
If they're not installed yet, then install Maven and LensKit inside a directory. 
Set environment variable M2_HOME, point it to the Maven directory. E.g. "C:\java\apache-maven-3.3.3" in Windows.
Add path of the LensKit's and Maven's binary directories, 
C:\java\lenskit-2.2\bin;%M2_HOME%\bin;%JAVA_HOME%\bin



Now we're ready. 
Create Maven project, run in command prompt:
  mvn archetype:generate


Enter apply filter = "lenskit",
Choose archetype = 1 = "lenskit-archetype-fancy-analysis",
Choose version based on your lenskit.

Enter groupId = "org.grouplens.lenskit.demos",
Enter artifactId = "lenskit-example",
Accept default version,

Accept default package, 
Confirm = Y.


 
Import the project into Intellij IDEA (or Eclipse).

  • open Maven project (pom.xml of the lenskit-example) 
  • run | edit configurations
  • click (+) button on top-left (add new configuration)
  • choose Maven configuration
  • enter name and command line, e.g. "Publish" and "lenskit-publish"
  • Run...


Possible errors: 
If error "Project JDK is not specified" occured, add JDK to the project, (File | Project Structure).

 

In case of this error,
"Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match"
then, check out this bug report,  or,
open up the IntelliJ's Settings dialog, then in Maven | Runner options set VM options:
-Dmaven.multiModuleProjectDirectory=MAVEN_HOME_PATH



If the "java.io.IOException: Cannot run program pdflatex" error happened, we have 2 choices: 
  • Install TeXLive  (or its alternative) to get LaTeX, because the eval demonstration uses LaTeX to build a paper containing the results of the evaluation. The problem is that we do not have LaTeX installed (or if we do, the demo cannot find it). 
  • or, delete (or comment out) the LaTeX plugin section from the script's pom.xml to disable it.
Remember that in Windows, we must run the TeXLive binary installer as administrator,
Warning!! installation size of TeXLive is huge, around 4 GB of files will be downloaded!!

Some reference vids:
https://www.youtube.com/watch?v=k7v-CuD8jbQ
http://www.youtube.com/watch?v=iUcgGj1pxRw

Console text (run time), as reference:

[INFO] Running evaluator with 1 threads
[INFO] Building LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0}
[INFO] Built ItemItem in 0:00:00.239
[INFO] Measuring ItemItem on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0
[INFO] Testing LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0} (189 users)
[INFO] constructing build context
[INFO] built model for 1680 items in 3.737 s
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:04.700
[INFO] Tested ItemItem in 0:00:05.371
[INFO] RMSE: 0.9537749012846594
 

[INFO] Building LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0}
[INFO] Built ExtendedItemUserMean in 0:00:00.000
[INFO] Measuring ExtendedItemUserMean on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0
[INFO] Testing LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:00.510
[INFO] Tested ExtendedItemUserMean in 0:00:00.598
[INFO] RMSE: 0.9873232890789356
 

[INFO] Building LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1}
[INFO] Built ItemItem in 0:00:00.245
[INFO] Measuring ItemItem on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1
[INFO] Testing LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1} (189 users)
[INFO] constructing build context
[INFO] built model for 1680 items in 3.550 s
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:03.877
[INFO] Tested ItemItem in 0:00:04.433
[INFO] RMSE: 0.9419440401588824
 

[INFO] Building LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1}
[INFO] Built UserUser in 0:00:00.000
[INFO] Measuring UserUser on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1
[INFO] Testing LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:05.684
[INFO] Tested UserUser in 0:00:11.751
[INFO] RMSE: 0.9801525361516503
 

[INFO] Building LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4}
[INFO] Built ItemItem in 0:00:00.231
[INFO] Measuring ItemItem on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4
[INFO] Testing LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4} (188 users)
[INFO] constructing build context
[INFO] built model for 1682 items in 3.496 s
[INFO] tested 100 of 188 users (53.19%), ETA 0:00:03.713
[INFO] Tested ItemItem in 0:00:04.291
[INFO] RMSE: 0.9736779904289198
 

[INFO] Building LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3}
[INFO] Built ItemItem in 0:00:00.261
[INFO] Measuring ItemItem on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3
[INFO] Testing LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3} (188 users)
[INFO] constructing build context
[INFO] built model for 1682 items in 3.619 s
[INFO] tested 100 of 188 users (53.19%), ETA 0:00:03.886
[INFO] Tested ItemItem in 0:00:04.493
[INFO] RMSE: 0.9503134019133949
 

[INFO] Building LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3}
[INFO] Built ExtendedItemUserMean in 0:00:00.000
[INFO] Measuring ExtendedItemUserMean on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3
[INFO] Testing LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3} (188 users)
[INFO] tested 100 of 188 users (53.19%), ETA 0:00:00.145
[INFO] Tested ExtendedItemUserMean in 0:00:00.187
[INFO] RMSE: 0.9882427507326965
 

[INFO] Building LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1}
[INFO] Built ExtendedItemUserMean in 0:00:00.000
[INFO] Measuring ExtendedItemUserMean on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1
[INFO] Testing LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.1} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:00.136
[INFO] Tested ExtendedItemUserMean in 0:00:00.176
[INFO] RMSE: 0.9869861652787851
 

[INFO] Building LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0}
[INFO] Built UserUser in 0:00:00.000
[INFO] Measuring UserUser on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0
[INFO] Testing LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.0} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:05.614
[INFO] Tested UserUser in 0:00:11.675
[INFO] RMSE: 0.9744192920050504
 

[INFO] Building LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2}
[INFO] Built ItemItem in 0:00:00.341
[INFO] Measuring ItemItem on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2
[INFO] Testing LenskitAlgorithm(ItemItem) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2} (189 users)
[INFO] constructing build context
[INFO] built model for 1680 items in 3.514 s
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:03.827
[INFO] Tested ItemItem in 0:00:04.372
[INFO] RMSE: 0.9366137795552605
 

[INFO] Building LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2}
[INFO] Built UserUser in 0:00:00.000
[INFO] Measuring UserUser on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2
[INFO] Testing LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:05.617
[INFO] Tested UserUser in 0:00:11.650
[INFO] RMSE: 0.945923699237089
 

[INFO] Building LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2}
[INFO] Built ExtendedItemUserMean in 0:00:00.000
[INFO] Measuring ExtendedItemUserMean on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2
[INFO] Testing LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.2} (189 users)
[INFO] tested 100 of 189 users (52.91%), ETA 0:00:00.127
[INFO] Tested ExtendedItemUserMean in 0:00:00.166
[INFO] RMSE: 0.9498674162436282
 

[INFO] Building LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3}
[INFO] Built UserUser in 0:00:00.000
[INFO] Measuring UserUser on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3
[INFO] Testing LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.3} (188 users)
[INFO] tested 100 of 188 users (53.19%), ETA 0:00:05.775
[INFO] Tested UserUser in 0:00:11.875
[INFO] RMSE: 0.9854596734780366
 

[INFO] Building LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4}
[INFO] Built UserUser in 0:00:00.000
[INFO] Measuring UserUser on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4
[INFO] Testing LenskitAlgorithm(UserUser) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4} (188 users)
[INFO] tested 100 of 188 users (53.19%), ETA 0:00:05.434
[INFO] Tested UserUser in 0:00:11.431
[INFO] RMSE: 0.9815694436874106
 

[INFO] Building LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4}
[INFO] Built ExtendedItemUserMean in 0:00:00.000
[INFO] Measuring ExtendedItemUserMean on D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4
[INFO] Testing LenskitAlgorithm(ExtendedItemUserMean) on {TTDataSet D:\EB\coursera\intro-recommender-system\me\lenskit-example/target/data//ml100k/u.data.4} (188 users)

[INFO] tested 100 of 188 users (53.19%), ETA 0:00:00.125
[INFO] Tested ExtendedItemUserMean in 0:00:00.164
[INFO] RMSE: 0.9942713791755641


[INFO] evaluation train-test completed
[INFO] evaluate finished in 1.423 min
[INFO] running target analyze
[INFO] beginning execution of analyze
[INFO] running task exec
[INFO] analyze finished in 21.29 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:07 min
[INFO] Finished at: 2015-09-03T03:35:44+07:00
[INFO] Final Memory: 61M/150M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

Finally, enjoy the collaborative filtering approach: user-based recommender, item-based recommender, ... content-based filtering approach, ... (see also Video 5.9 - Using the LensKit Evaluator).
^__^