-
-
Save asw456/03d3ab4ff701be05b471 to your computer and use it in GitHub Desktop.
This file contains 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment