Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Added the first complete draft for the talk. It contains a SVD and…

… a User based example
  • Loading branch information...
commit be01387b9989e98b8bcb379cb7da2b17ec7fa867 1 parent 4233404
Manuel Blechschmidt authored
View
135 .classpath
@@ -1,136 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
- <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
- <classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.2/commons-cli-1.2.jar" sourcepath="M2_REPO/commons-cli/commons-cli/1.2/commons-cli-1.2-sources.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/mahout/commons/commons-cli/2.0-mahout/commons-cli-2.0-mahout.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/manuel/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3-javadoc.jar!/"/>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-dbcp/commons-dbcp/1.2.2/commons-dbcp-1.2.2.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-math/2.1/commons-math-2.1.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.4/commons-pool-1.4.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/com/google/collections/google-collections/1.0-rc2/google-collections-1.0-rc2.jar" sourcepath="M2_REPO/com/google/collections/google-collections/1.0-rc2/google-collections-1.0-rc2-sources.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/com/google/guava/guava/r03/guava-r03.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/hadoop/hadoop-core/0.20.2/hadoop-core-0.20.2.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/javax/javaee-api/6.0/javaee-api-6.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/lucene/lucene-analyzers/3.1.0/lucene-analyzers-3.1.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/lucene/lucene-core/3.1.0/lucene-core-3.1.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/mahout/mahout-collections/1.0/mahout-collections-1.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/mahout/mahout-core/0.5/mahout-core-0.5.jar" sourcepath="M2_REPO/org/apache/mahout/mahout-core/0.5/mahout-core-0.5-sources.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/mahout/mahout-math/0.5/mahout-math-0.5.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.0/slf4j-api-1.6.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/solr/solr-commons-csv/3.1.0/solr-commons-csv-3.1.0.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/uncommons/maths/uncommons-maths/1.2/uncommons-maths-1.2.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/uncommons/watchmaker/watchmaker-framework/0.6.2/watchmaker-framework-0.6.2.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="target/classes"/>
View
4 .project
@@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
View
8 .settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
-#Sun Feb 19 18:47:39 CET 2012
+#Sun Mar 18 23:26:35 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.5
View
66 docs/BedConExamples.R
@@ -0,0 +1,66 @@
+# replace unknown values with 0
+# Carrots Grass Pork Beef Corn Fish
+Rabbit <- c(10, 7, 1, 2, NA, 1)
+Cow <- c( 7, 10, NA, NA, NA, NA)
+Dog <- c(NA, 1, 10, 10, NA, NA)
+Pig <- c( 5, 6, 4, NA, 7, 3)
+Chicken <- c( 7, 6, 2, NA, 10, NA)
+Pinguin <- c( 2, 2, NA, 2, 2, 10)
+Bear <- c( 2, NA, 8, 8, 2, 7)
+Lion <- c(NA, NA, 9, 10, 2, NA)
+Tiger <- c(NA, NA, 8, NA, NA, 5)
+Antilope <- c( 6, 10, 1, 1, NA, NA)
+Wolf <- c( 1, NA, NA, 8, NA, 4)
+Sheep <- c(NA, 8, NA, NA, NA, 2)
+# all the animals
+animals <- c("Rabbit","Cow","Dog","Pig","Chicken","Pinguin","Bear","Lion","Tiger","Antilope","Wolf","Sheep")
+# all the foods
+foods <- c("Carrots","Grass","Pork", "Beef", "Corn", "Fish")
+matrixRowAndColNames <- list(animals, foods)
+# create a matrix from the ratings
+animal2foodRatings <- matrix(
+ data=c(Rabbit,Cow,Dog,Pig,Chicken,Pinguin,Bear,Lion,Tiger,Antilope,Wolf,Sheep),
+ nrow=12,ncol=6,byrow=TRUE, matrixRowAndColNames)
+
+animal2foodRatingsWithMean <- animal2foodRatings
+animal2foodRatingsWithMean[is.na(animal2foodRatingsWithMean)] <- mean(rowMeans(animal2foodRatingsRecMatrix))
+
+FactorStructure <- svd(animal2foodRatingsWithMean)
+#
+D <- diag(FactorStructure$d)
+PredictedRatings <- FactorStructure$u %*% D %*% t(FactorStructure$v)
+dimnames(PredictedRatings) <- matrixRowAndColNames
+
+PredictiveMatrix <- matrix(nrow=length(animals), ncol=length(foods))
+dimnames(PredictiveMatrix) <- matrixRowAndColNames
+# Sheep Carrots prediction
+k <- 2
+for(animal in 1:length(animals)) {
+ for(food in 1:length(foods)) {
+ PredictiveMatrix[animal,food] <- (((FactorStructure$u[animal,1:k]*sqrt(FactorStructure$d[1:k]))%*%(sqrt(FactorStructure$d[1:k])*t(FactorStructure$v)[1:k,food]))[1,1])
+ }
+}
+PredictiveMatrix
+library(recommenderlab)
+
+animal2foodRatingsRecMatrix <- as(animal2foodRatings, "realRatingMatrix")
+animal2foodRatingsRecMatrix_n <- normalize(animal2foodRatingsRecMatrix)
+animal2foodRatingsRecMatrix_n2 <- normalize(animal2foodRatingsRecMatrix, method="Z-score")
+
+# Average user rating
+mean(rowMeans(animal2foodRatingsRecMatrix))
+# Average number of ratings per User
+mean(rowCounts(animal2foodRatingsRecMatrix))
+# Average number of ratings per Item
+mean(colCounts(animal2foodRatingsRecMatrix))
+# Amount of all ratings
+length(getRatings(animal2foodRatingsRecMatrix))
+# Histogram of ratings
+hist(getRatings(animal2foodRatingsRecMatrix), breaks=10, main=paste("Distribution of Ratings"))
+
+image(animal2foodRatingsRecMatrix, main="Raw Data")
+image(animal2foodRatingsRecMatrix_n, main="Centered")
+image(animal2foodRatingsRecMatrix_n2, main="Z-Score Normalization")
+
+rec <- Recommender(animal2foodRatingsRecMatrix[1:10,], method = "IBCF")
+recommenderRegistry$get_entry_names()
View
BIN  docs/Bundeling.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/DemoFoods.ods
Binary file not shown
View
BIN  docs/DistributionOfRatings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/MavenPOM_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/MavenPOM_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/PredictedRatings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/Predicted_K_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/RawRatingDataPlotted.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/Raw_Data_For_Ratings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1  docs/RecommenderArchitecture.json
@@ -0,0 +1 @@
+{"resourceId":"oryx-canvas123","properties":{"title":""},"stencil":{"id":"Diagram"},"childShapes":[{"resourceId":"oryx_4D7148C7-5718-4BF4-9173-91583FEAE422","properties":{"title":"Glassfish Java EE 6 Server\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[{"resourceId":"oryx_6EDA03D2-E2AA-496D-AB93-23EFFC6EFC94","properties":{"title":"facebook-recommender-demo.war\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[{"resourceId":"oryx_B7EAC1D3-8EFD-471A-8D78-6DE258E1E0A5","properties":{"title":"FacebookRecommenderREST","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[],"outgoing":[{"resourceId":"oryx_C381AE76-5E36-42BD-9337-E329A1F30007"},{"resourceId":"oryx_64C004E7-971E-49AC-891F-E0B6D2212719"}],"bounds":{"lowerRight":{"x":199,"y":233},"upperLeft":{"x":5,"y":204}},"dockers":[]},{"resourceId":"oryx_DBF60405-87F7-4DE6-AF7D-A01B46E8093D","properties":{"title":"FacebookRecommenderSOAP","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[],"outgoing":[{"resourceId":"oryx_BE25A304-1BFE-4060-9297-73A259E82B70"},{"resourceId":"oryx_21AEC748-A2E5-44AE-A135-144C796AB5EE"}],"bounds":{"lowerRight":{"x":409,"y":233},"upperLeft":{"x":215,"y":204}},"dockers":[]},{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976","properties":{"title":"FacebookRecommender","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[{"resourceId":"oryx_CC10E9CF-D509-4CED-BA4F-C4929713CF96","properties":{"title":"Recommender","url":"","color":"#ffffff"},"stencil":{"id":"Agent"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":393,"y":36},"upperLeft":{"x":279,"y":10}},"dockers":[]}],"outgoing":[{"resourceId":"oryx_268135AE-C5F2-4773-BF01-7F38E8DD647A"},{"resourceId":"oryx_7A498CEE-5877-4D88-B085-08AE811317D6"}],"bounds":{"lowerRight":{"x":406,"y":161},"upperLeft":{"x":6,"y":116}},"dockers":[]},{"resourceId":"oryx_C5D7D260-318B-4F88-9F70-1B15E2036528","properties":{"title":"DemoFriendsLikes.csv","url":"","color":"#ffffff"},"stencil":{"id":"Storage"},"childShapes":[],"outgoing":[{"resourceId":"oryx_F0AB42FC-009B-4183-A339-94760495585D"}],"bounds":{"lowerRight":{"x":159,"y":87},"upperLeft":{"x":8,"y":35}},"dockers":[]},{"resourceId":"oryx_2517A7B1-B1F3-4780-AAA4-A49284B9E27D","properties":{"title":"","color":"#ffffff"},"stencil":{"id":"Channel"},"childShapes":[],"outgoing":[{"resourceId":"oryx_E3075188-4CD3-43D7-9BC4-BA578ED4B151"}],"bounds":{"lowerRight":{"x":110,"y":188},"upperLeft":{"x":94,"y":172}},"dockers":[]},{"resourceId":"oryx_3E9B0447-EE9F-41B0-812B-8A0F03CF5206","properties":{"label":"local client view"},"stencil":{"id":"TextLabel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":138,"y":183.5},"upperLeft":{"x":114,"y":171.5}},"dockers":[]},{"resourceId":"oryx_A1AD003D-D003-4381-89B3-068B9A64030D","properties":{"title":"","color":"#ffffff"},"stencil":{"id":"Channel"},"childShapes":[],"outgoing":[{"resourceId":"oryx_8E653F1C-6798-4C43-9905-7FEF4B2C529E"}],"bounds":{"lowerRight":{"x":320,"y":188},"upperLeft":{"x":304,"y":172}},"dockers":[]},{"resourceId":"oryx_FA2332D3-0982-4C3A-A09A-4EBF8B8BDFB4","properties":{"label":"local client view"},"stencil":{"id":"TextLabel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":346,"y":186.5},"upperLeft":{"x":322,"y":174.5}},"dockers":[]},{"resourceId":"oryx_6F3DE216-7514-4B5A-94ED-689C7864468D","properties":{"title":"IDMigrator","url":"","color":"#ffffff"},"stencil":{"id":"Storage"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":279,"y":93},"upperLeft":{"x":208,"y":68}},"dockers":[]},{"resourceId":"oryx_AFAC98B1-CD90-45FB-B425-E1E97262CD06","properties":{"title":"DataModel","url":"","color":"#ffffff"},"stencil":{"id":"Storage"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":395,"y":93},"upperLeft":{"x":287,"y":28}},"dockers":[]}],"outgoing":[],"bounds":{"lowerRight":{"x":429,"y":300},"upperLeft":{"x":14,"y":55}},"dockers":[]}],"outgoing":[],"bounds":{"lowerRight":{"x":593,"y":357.5},"upperLeft":{"x":154,"y":42.5}},"dockers":[]},{"resourceId":"oryx_771D4E66-A6C7-4238-A36F-83441849F3A2","properties":{"title":"","color":"#ffffff"},"stencil":{"id":"Channel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":278,"y":397},"upperLeft":{"x":262,"y":381}},"dockers":[]},{"resourceId":"oryx_C427C37C-60FA-40C7-AE5B-C99DE4D2413A","properties":{"label":"REST"},"stencil":{"id":"TextLabel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":282,"y":413.5},"upperLeft":{"x":258,"y":401.5}},"dockers":[]},{"resourceId":"oryx_659A3A10-4766-40D9-9EBE-3AA856868B02","properties":{"title":"","color":"#ffffff"},"stencil":{"id":"Channel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":488,"y":397},"upperLeft":{"x":472,"y":381}},"dockers":[]},{"resourceId":"oryx_C813B08C-3D50-414E-ADF4-E0BEDA0165D4","properties":{"label":"SOAP"},"stencil":{"id":"TextLabel"},"childShapes":[],"outgoing":[],"bounds":{"lowerRight":{"x":492,"y":413.5},"upperLeft":{"x":468,"y":401.5}},"dockers":[]},{"resourceId":"oryx_C381AE76-5E36-42BD-9337-E329A1F30007","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_771D4E66-A6C7-4238-A36F-83441849F3A2"}],"bounds":{"lowerRight":{"x":271,"y":380.015625},"upperLeft":{"x":269,"y":330.6875}},"dockers":[{"x":97.00000000000003,"y":14.5},{"x":8,"y":8}],"target":{"resourceId":"oryx_771D4E66-A6C7-4238-A36F-83441849F3A2"}},{"resourceId":"oryx_BE25A304-1BFE-4060-9297-73A259E82B70","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_659A3A10-4766-40D9-9EBE-3AA856868B02"}],"bounds":{"lowerRight":{"x":481,"y":380.015625},"upperLeft":{"x":479,"y":330.6875}},"dockers":[{"x":97,"y":14.5},{"x":8,"y":8}],"target":{"resourceId":"oryx_659A3A10-4766-40D9-9EBE-3AA856868B02"}},{"resourceId":"oryx_64C004E7-971E-49AC-891F-E0B6D2212719","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_2517A7B1-B1F3-4780-AAA4-A49284B9E27D"}],"bounds":{"lowerRight":{"x":271,"y":300.5625},"upperLeft":{"x":269,"y":285.71875}},"dockers":[{"x":97,"y":14.5},{"x":8,"y":8}],"target":{"resourceId":"oryx_2517A7B1-B1F3-4780-AAA4-A49284B9E27D"}},{"resourceId":"oryx_E3075188-4CD3-43D7-9BC4-BA578ED4B151","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}],"bounds":{"lowerRight":{"x":271,"y":268.92509419806163},"upperLeft":{"x":269,"y":259.0216707950157}},"dockers":[{"x":8,"y":8},{"x":96,"y":29.371859191139038}],"target":{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}},{"resourceId":"oryx_F0AB42FC-009B-4183-A339-94760495585D","properties":{"label":""},"stencil":{"id":"WriteAccess"},"childShapes":[],"outgoing":[{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}],"bounds":{"lowerRight":{"x":252.5,"y":212.90171830976465},"upperLeft":{"x":250.5,"y":184.8924542253088}},"dockers":[{"x":75.50000000000001,"y":26},{"x":77.5,"y":18.868957746352862}],"target":{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}},{"resourceId":"oryx_21AEC748-A2E5-44AE-A135-144C796AB5EE","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_A1AD003D-D003-4381-89B3-068B9A64030D"}],"bounds":{"lowerRight":{"x":481,"y":300.5625},"upperLeft":{"x":479,"y":285.71875}},"dockers":[{"x":97,"y":14.5},{"x":8,"y":8}],"target":{"resourceId":"oryx_A1AD003D-D003-4381-89B3-068B9A64030D"}},{"resourceId":"oryx_8E653F1C-6798-4C43-9905-7FEF4B2C529E","properties":{"label":""},"stencil":{"id":"BidirectionalConnection"},"childShapes":[],"outgoing":[{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}],"bounds":{"lowerRight":{"x":481,"y":269.3328003419314},"upperLeft":{"x":479,"y":259.0461723566709}},"dockers":[{"x":8,"y":8},{"x":306,"y":31.235658705972014}],"target":{"resourceId":"oryx_96959483-17F7-463A-99E4-B9647FAC3976"}},{"resourceId":"oryx_7A498CEE-5877-4D88-B085-08AE811317D6","properties":{"label":""},"stencil":{"id":"ModifyingAccess"},"childShapes":[],"outgoing":[{"resourceId":"oryx_6F3DE216-7514-4B5A-94ED-689C7864468D"}],"bounds":{"lowerRight":{"x":412.5,"y":212.53560740221542},"upperLeft":{"x":410.5,"y":190.8452024674051}},"dockers":[{"x":237.5,"y":6.616275439662701},{"x":35.5,"y":12.5}],"target":{"resourceId":"oryx_6F3DE216-7514-4B5A-94ED-689C7864468D"}},{"resourceId":"oryx_268135AE-C5F2-4773-BF01-7F38E8DD647A","properties":{"label":""},"stencil":{"id":"ModifyingAccess"},"childShapes":[],"outgoing":[{"resourceId":"oryx_AFAC98B1-CD90-45FB-B425-E1E97262CD06"}],"bounds":{"lowerRight":{"x":510,"y":212.65440792113247},"upperLeft":{"x":508,"y":191.27955659425686}},"dockers":[{"x":335,"y":15.737642139049598},{"x":54,"y":32.5}],"target":{"resourceId":"oryx_AFAC98B1-CD90-45FB-B425-E1E97262CD06"}}],"bounds":{"lowerRight":{"x":1485,"y":1050},"upperLeft":{"x":0,"y":0}},"stencilset":{"url":"/oryx//stencilsets/fmcblockdiagram/fmcblockdiagram.json","namespace":"http://www.fmc-modeling.org/stencilsets/fmcblockdiagram#"},"ssextensions":[]}
View
BIN  docs/RecommenderArchitecture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/S.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/Talk-BedCon-Berlin-2012.odp
Binary file not shown
View
BIN  docs/Talk-BedCon-Berlin-2012.pdf
Binary file not shown
View
BIN  docs/U.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/V_t.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  pom.xml
@@ -52,7 +52,7 @@
<configuration>
<goalPrefix>glassfish</goalPrefix>
<app>target/${project.artifactId}.${project.packaging}</app>
- <port>8080</port>
+ <port>8010</port>
</configuration>
</plugin>
</plugins>
View
133 src/main/java/de/apaxo/bedcon/AnimalFoodRecommender.java
@@ -0,0 +1,133 @@
+package de.apaxo.bedcon;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.impl.common.FastByIDMap;
+import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
+import org.apache.mahout.cf.taste.impl.model.GenericPreference;
+import org.apache.mahout.cf.taste.impl.model.GenericUserPreferenceArray;
+import org.apache.mahout.cf.taste.impl.model.MemoryIDMigrator;
+import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
+import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
+import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
+import org.apache.mahout.cf.taste.model.DataModel;
+import org.apache.mahout.cf.taste.model.Preference;
+import org.apache.mahout.cf.taste.model.PreferenceArray;
+import org.apache.mahout.cf.taste.recommender.RecommendedItem;
+
+/**
+ * This class shows some examples which are implemented
+ * in java for showing how to use the different recommenders
+ * in java.
+ * It uses animals and foods as examples.
+ * @author Manuel Blechschmidt <blechschmidt@apaxo.de>
+ *
+ */
+public class AnimalFoodRecommender {
+
+ private MemoryIDMigrator id2thing = new MemoryIDMigrator();
+ private List<String> foods = new ArrayList<String>();
+ private List<String> animals = new ArrayList<String>();
+ private DataModel model;
+
+ private Float[][] preferences = new Float[][] {
+ // Carrots Grass Pork Beef Corn Fish
+ // Rabbit
+ new Float[] {10f, 7f, 1f, 2f, null, 1f},
+ // Cow
+ new Float[] { 7f, 10f, null, null, null, null},
+ // Dog
+ new Float[] {null, 1f, 10f, 10f, null, null},
+ // Pig
+ new Float[] { 5f, 6f, 4f, null, 7f, 3f},
+ // Chicken
+ new Float[] { 7f, 6f, 2f, null, 10f, null},
+ // Pinguin
+ new Float[] { 2f, 2f, null, 2f, 2f, 10f},
+ // Bear
+ new Float[] { 2f, null, 8f, 8f, 2f, 7f},
+ // Lion
+ new Float[] {null, null, 9f, 10f, 2f, null},
+ // Tiger
+ new Float[] {null, null, 8f, null, null, 5f},
+ // Antilope
+ new Float[] { 6f, 10f, 1f, 1f, null, null},
+ // Wolf
+ new Float[] { 1f, null, null, 8f, null, 3f},
+ // Sheep
+ new Float[] {null, 8f, null, null, null, 2f}
+ };
+
+
+ public AnimalFoodRecommender() {
+ initMemoryMigrator();
+ initDataModel();
+ initRecommender();
+ }
+
+ /**
+ * This function generates ids for
+ * the different things in the demp
+ */
+ private void initMemoryMigrator() {
+ foods.add("Carrots");
+ foods.add("Grass");
+ foods.add("Pork");
+ foods.add("Beef");
+ foods.add("Corn");
+ foods.add("Fish");
+ for(String food : foods) {
+ id2thing.storeMapping(id2thing.toLongID(food), food);
+ System.out.println(food+" = "+id2thing.toLongID(food));
+ }
+ animals.add("Rabbit");
+ animals.add("Cow");
+ animals.add("Dog");
+ animals.add("Pig");
+ animals.add("Chicken");
+ animals.add("Pinguin");
+ animals.add("Bear");
+ animals.add("Lion");
+ animals.add("Tiger");
+ animals.add("Antilope");
+ animals.add("Wolf");
+ animals.add("Sheep");
+ for(String animal : animals) {
+ id2thing.storeMapping(id2thing.toLongID(animal), animal);
+ System.out.println(animal+" = "+id2thing.toLongID(animal));
+ }
+ }
+
+ public void initDataModel() {
+ FastByIDMap<PreferenceArray> preferenceMap = new FastByIDMap<PreferenceArray>();
+ for(int i=0;i<animals.size();i++) {
+ List<Preference> userPreferences = new ArrayList<Preference>();
+ long userId = id2thing.toLongID(animals.get(i));
+ for(int j=0;j<foods.size();j++) {
+ if(preferences[i][j] != null) {
+ userPreferences.add(new GenericPreference(userId, id2thing.toLongID(foods.get(j)), preferences[i][j]));
+ }
+ }
+ GenericUserPreferenceArray userArray = new GenericUserPreferenceArray(userPreferences);
+ preferenceMap.put(userId, userArray);
+ }
+ model = new GenericDataModel(preferenceMap);
+ }
+
+ public void initRecommender() {
+ try {
+ GenericUserBasedRecommender recommender = new GenericUserBasedRecommender(model, new NearestNUserNeighborhood(3, new PearsonCorrelationSimilarity(model), model), new PearsonCorrelationSimilarity(model));
+ for(RecommendedItem r : recommender.recommend(id2thing.toLongID("Wolf"), 3)) {
+ System.out.println("Wolf should eat: "+id2thing.toStringID(r.getItemID())+" Rating: "+r.getValue());
+ }
+ } catch (TasteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ new AnimalFoodRecommender();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.