Permalink
Browse files

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

… a User based example
  • Loading branch information...
1 parent 4233404 commit be01387b9989e98b8bcb379cb7da2b17ec7fa867 Manuel Blechschmidt committed Mar 18, 2012
View
@@ -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
@@ -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>
@@ -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
@@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit be01387

Please sign in to comment.