Created
September 12, 2014 16:28
-
-
Save pferrel/9cfee8b5723bb2e2a22c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.mahout.examples | |
import org.apache.mahout.drivers._ | |
import org.apache.mahout.math.cf.SimilarityAnalysis | |
object RecommenderDriver extends MahoutDriver { | |
/** | |
* @param args Command line args, if empty a help message is printed. | |
*/ | |
override def main(args: Array[String]): Unit = { | |
process | |
} | |
override def process: Unit = { | |
start("local", "spark-recommender") | |
// Read user / item data | |
val readSchema = new DefaultElementReadSchema() | |
val reader = new TextDelimitedIndexedDatasetReader(readSchema) | |
val indexedDatasetA = reader.readElementsFrom("data/article_views.txt") | |
// Run cooccurrence analysis | |
val cooccurrences = SimilarityAnalysis.cooccurrences(indexedDatasetA.matrix, 0xdeadbeef, Int.MaxValue, Int.MaxValue) | |
val indicatorDataset = IndexedDataset(cooccurrences(0), indexedDatasetA.columnIDs, indexedDatasetA.columnIDs) | |
// Print results | |
val writeSchema = new DefaultDRMWriteSchema() | |
val writer = new TextDelimitedIndexedDatasetWriter(writeSchema) | |
writer.writeTo(indicatorDataset, "data/indicators") | |
stop | |
} | |
} |
Can you please tell me what dependencies we need. I have tried multiple options but couldn't find cf.SimilarityAnalysis class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you give a sample about article_views.txt?