Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A9C94200CA8 for ; Fri, 5 May 2017 03:41:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A6E0A160BC6; Fri, 5 May 2017 01:41:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 410E8160BC5 for ; Fri, 5 May 2017 03:41:10 +0200 (CEST) Received: (qmail 58712 invoked by uid 500); 5 May 2017 01:41:07 -0000 Mailing-List: contact commits-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list commits@mahout.apache.org Received: (qmail 58187 invoked by uid 99); 5 May 2017 01:41:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 May 2017 01:41:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1B9C8E9809; Fri, 5 May 2017 01:41:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: rawkintrevo@apache.org To: commits@mahout.apache.org Date: Fri, 05 May 2017 01:41:14 -0000 Message-Id: <6a68cf33c4194868a8f47c4074214ac5@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/62] [abbrv] mahout git commit: WEBSITE Porting Old Website archived-at: Fri, 05 May 2017 01:41:12 -0000 http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/distributed/spark-bindings/faq.md ---------------------------------------------------------------------- diff --git a/website/docs/distributed/spark-bindings/faq.md b/website/docs/distributed/spark-bindings/faq.md new file mode 100644 index 0000000..9649e3b --- /dev/null +++ b/website/docs/distributed/spark-bindings/faq.md @@ -0,0 +1,52 @@ +--- +layout: default +title: FAQ +theme: + name: retro-mahout +--- + +# FAQ for using Mahout with Spark + +**Q: Mahout Spark shell doesn't start; "ClassNotFound" problems or various classpath problems.** + +**A:** So far as of the time of this writing all reported problems starting the Spark shell in Mahout were revolving +around classpath issues one way or another. + +If you are getting method signature like errors, most probably you have mismatch between Mahout's Spark dependency +and actual Spark installed. (At the time of this writing the HEAD depends on Spark 1.1.0) but check mahout/pom.xml. + +Troubleshooting general classpath issues is pretty straightforward. Since Mahout is using Spark's installation +and its classpath as reported by Spark itself for Spark-related dependencies, it is important to make sure +the classpath is sane and is made available to Mahout: + +1. Check Spark is of correct version (same as in Mahout's poms), is compiled and SPARK_HOME is set. +2. Check Mahout is compiled and MAHOUT_HOME is set. +3. Run `$SPARK_HOME/bin/compute-classpath.sh` and make sure it produces sane result with no errors. +If it outputs something other than a straightforward classpath string, most likely Spark is not compiled/set correctly (later spark versions require +`sbt/sbt assembly` to be run, simply runnig `sbt/sbt publish-local` is not enough any longer). +4. Run `$MAHOUT_HOME/bin/mahout -spark classpath` and check that path reported in step (3) is included. + +**Q: I am using the command line Mahout jobs that run on Spark or am writing my own application that uses +Mahout's Spark code. When I run the code on my cluster I get ClassNotFound or signature errors during serialization. +What's wrong?** + +**A:** The Spark artifacts in the maven ecosystem may not match the exact binary you are running on your cluster. This may +cause class name or version mismatches. In this case you may wish +to build Spark yourself to guarantee that you are running exactly what you are building Mahout against. To do this follow these steps +in order: + +1. Build Spark with maven, but **do not** use the "package" target as described on the Spark site. Build with the "clean install" target instead. +Something like: "mvn clean install -Dhadoop1.2.1" or whatever your particular build options are. This will put the jars for Spark +in the local maven cache. +2. Deploy **your** Spark build to your cluster and test it there. +3. Build Mahout. This will cause maven to pull the jars for Spark from the local maven cache and may resolve missing +or mis-identified classes. +4. if you are building your own code do so against the local builds of Spark and Mahout. + +**Q: The implicit SparkContext 'sc' does not work in the Mahout spark-shell.** + +**A:** In the Mahout spark-shell the SparkContext is called 'sdc', where the 'd' stands for distributed. + + + + http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/distributed/spark-bindings/index.md ---------------------------------------------------------------------- diff --git a/website/docs/distributed/spark-bindings/index.md b/website/docs/distributed/spark-bindings/index.md new file mode 100644 index 0000000..54324c7 --- /dev/null +++ b/website/docs/distributed/spark-bindings/index.md @@ -0,0 +1,104 @@ +--- +layout: default +title: Spark Bindings +theme: + name: retro-mahout +--- + +# Scala & Spark Bindings: +*Bringing algebraic semantics* + +## What is Scala & Spark Bindings? + +In short, Scala & Spark Bindings for Mahout is Scala DSL and algebraic optimizer of something like this (actual formula from **(d)spca**) + + +`\[\mathbf{G}=\mathbf{B}\mathbf{B}^{\top}-\mathbf{C}-\mathbf{C}^{\top}+\mathbf{s}_{q}\mathbf{s}_{q}^{\top}\boldsymbol{\xi}^{\top}\boldsymbol{\xi}\]` + +bound to in-core and distributed computations (currently, on Apache Spark). + + +Mahout Scala & Spark Bindings expression of the above: + + val g = bt.t %*% bt - c - c.t + (s_q cross s_q) * (xi dot xi) + +The main idea is that a scientist writing algebraic expressions cannot care less of distributed +operation plans and works **entirely on the logical level** just like he or she would do with R. + +Another idea is decoupling logical expression from distributed back-end. As more back-ends are added, +this implies **"write once, run everywhere"**. + +The linear algebra side works with scalars, in-core vectors and matrices, and Mahout Distributed +Row Matrices (DRMs). + +The ecosystem of operators is built in the R's image, i.e. it follows R naming such as %*%, +colSums, nrow, length operating over vectors or matices. + +Important part of Spark Bindings is expression optimizer. It looks at expression as a whole +and figures out how it can be simplified, and which physical operators should be picked. For example, +there are currently about 5 different physical operators performing DRM-DRM multiplication +picked based on matrix geometry, distributed dataset partitioning, orientation etc. +If we count in DRM by in-core combinations, that would be another 4, i.e. 9 total -- all of it for just +simple x %*% y logical notation. + +Please refer to the documentation for details. + +## Status + +This environment addresses mostly R-like Linear Algebra optmizations for +Spark, Flink and H20. + + +## Documentation + +* Scala and Spark bindings manual: [web](http://apache.github.io/mahout/doc/ScalaSparkBindings.html), [pdf](ScalaSparkBindings.pdf), [pptx](MahoutScalaAndSparkBindings.pptx) +* [Spark Bindings FAQ](faq.html) + + +## Distributed methods and solvers using Bindings + +* In-core ([ssvd]) and Distributed ([dssvd]) Stochastic SVD -- guinea pigs -- see the bindings manual +* In-core ([spca]) and Distributed ([dspca]) Stochastic PCA -- guinea pigs -- see the bindings manual +* Distributed thin QR decomposition ([dqrThin]) -- guinea pig -- see the bindings manual +* [Current list of algorithms](https://mahout.apache.org/users/basics/algorithms.html) + +[ssvd]: https://github.com/apache/mahout/blob/trunk/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/SSVD.scala +[spca]: https://github.com/apache/mahout/blob/trunk/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/SSVD.scala +[dssvd]: https://github.com/apache/mahout/blob/trunk/spark/src/main/scala/org/apache/mahout/sparkbindings/decompositions/DSSVD.scala +[dspca]: https://github.com/apache/mahout/blob/trunk/spark/src/main/scala/org/apache/mahout/sparkbindings/decompositions/DSPCA.scala +[dqrThin]: https://github.com/apache/mahout/blob/trunk/spark/src/main/scala/org/apache/mahout/sparkbindings/decompositions/DQR.scala + +## Reading RDDs and DataFrames into DRMs +TODO + + +TODO: Do we still want this? (I don't think so...) +## Related history of note + +* CLI and Driver for Spark version of item similarity -- [MAHOUT-1541](https://issues.apache.org/jira/browse/MAHOUT-1541) +* Command line interface for generalizable Spark pipelines -- [MAHOUT-1569](https://issues.apache.org/jira/browse/MAHOUT-1569) +* Cooccurrence Analysis / Item-based Recommendation -- [MAHOUT-1464](https://issues.apache.org/jira/browse/MAHOUT-1464) +* Spark Bindings -- [MAHOUT-1346](https://issues.apache.org/jira/browse/MAHOUT-1346) +* Scala Bindings -- [MAHOUT-1297](https://issues.apache.org/jira/browse/MAHOUT-1297) +* Interactive Scala & Spark Bindings Shell & Script processor -- [MAHOUT-1489](https://issues.apache.org/jira/browse/MAHOUT-1489) +* OLS tutorial using Mahout shell -- [MAHOUT-1542](https://issues.apache.org/jira/browse/MAHOUT-1542) +* Full abstraction of DRM apis and algorithms from a distributed engine -- [MAHOUT-1529](https://issues.apache.org/jira/browse/MAHOUT-1529) +* Port Naive Bayes -- [MAHOUT-1493](https://issues.apache.org/jira/browse/MAHOUT-1493) + +## Work in progress +* Text-delimited files for input and output -- [MAHOUT-1568](https://issues.apache.org/jira/browse/MAHOUT-1568) + + + +* *Your issue here!* + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/classify-a-doc-from-the-shell.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/classify-a-doc-from-the-shell.md b/website/docs/tutorials/classify-a-doc-from-the-shell.md deleted file mode 100644 index 0a237d1..0000000 --- a/website/docs/tutorials/classify-a-doc-from-the-shell.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -layout: page -title: Text Classification Example -theme: - name: mahout2 ---- - -# Building a text classifier in Mahout's Spark Shell - -This tutorial will take you through the steps used to train a Multinomial Naive Bayes model and create a text classifier based on that model using the ```mahout spark-shell```. - -## Prerequisites -This tutorial assumes that you have your Spark environment variables set for the ```mahout spark-shell``` see: [Playing with Mahout's Shell](http://mahout.apache.org/users/sparkbindings/play-with-shell.html). As well we assume that Mahout is running in cluster mode (i.e. with the ```MAHOUT_LOCAL``` environment variable **unset**) as we'll be reading and writing to HDFS. - -## Downloading and Vectorizing the Wikipedia dataset -*As of Mahout v. 0.10.0, we are still reliant on the MapReduce versions of ```mahout seqwiki``` and ```mahout seq2sparse``` to extract and vectorize our text. A* [*Spark implementation of seq2sparse*](https://issues.apache.org/jira/browse/MAHOUT-1663) *is in the works for Mahout v. 0.11.* However, to download the Wikipedia dataset, extract the bodies of the documentation, label each document and vectorize the text into TF-IDF vectors, we can simpmly run the [wikipedia-classifier.sh](https://github.com/apache/mahout/blob/master/examples/bin/classify-wikipedia.sh) example. - - Please select a number to choose the corresponding task to run - 1. CBayes (may require increased heap space on yarn) - 2. BinaryCBayes - 3. clean -- cleans up the work area in /tmp/mahout-work-wiki - Enter your choice : - -Enter (2). This will download a large recent XML dump of the Wikipedia database, into a ```/tmp/mahout-work-wiki``` directory, unzip it and place it into HDFS. It will run a [MapReduce job to parse the wikipedia set](http://mahout.apache.org/users/classification/wikipedia-classifier-example.html), extracting and labeling only pages with category tags for [United States] and [United Kingdom] (~11600 documents). It will then run ```mahout seq2sparse``` to convert the documents into TF-IDF vectors. The script will also a build and test a [Naive Bayes model using MapReduce](http://mahout.apache.org/users/classification/bayesian.html). When it is completed, you should see a confusion matrix on your screen. For this tutorial, we will ignore the MapReduce model, and build a new model using Spark based on the vectorized text output by ```seq2sparse```. - -## Getting Started - -Launch the ```mahout spark-shell```. There is an example script: ```spark-document-classifier.mscala``` (.mscala denotes a Mahout-Scala script which can be run similarly to an R script). We will be walking through this script for this tutorial but if you wanted to simply run the script, you could just issue the command: - - mahout> :load /path/to/mahout/examples/bin/spark-document-classifier.mscala - -For now, lets take the script apart piece by piece. You can cut and paste the following code blocks into the ```mahout spark-shell```. - -## Imports - -Our Mahout Naive Bayes imports: - - import org.apache.mahout.classifier.naivebayes._ - import org.apache.mahout.classifier.stats._ - import org.apache.mahout.nlp.tfidf._ - -Hadoop imports needed to read our dictionary: - - import org.apache.hadoop.io.Text - import org.apache.hadoop.io.IntWritable - import org.apache.hadoop.io.LongWritable - -## Read in our full set from HDFS as vectorized by seq2sparse in classify-wikipedia.sh - - val pathToData = "/tmp/mahout-work-wiki/" - val fullData = drmDfsRead(pathToData + "wikipediaVecs/tfidf-vectors") - -## Extract the category of each observation and aggregate those observations by category - - val (labelIndex, aggregatedObservations) = SparkNaiveBayes.extractLabelsAndAggregateObservations( - fullData) - -## Build a Muitinomial Naive Bayes model and self test on the training set - - val model = SparkNaiveBayes.train(aggregatedObservations, labelIndex, false) - val resAnalyzer = SparkNaiveBayes.test(model, fullData, false) - println(resAnalyzer) - -printing the ```ResultAnalyzer``` will display the confusion matrix. - -## Read in the dictionary and document frequency count from HDFS - - val dictionary = sdc.sequenceFile(pathToData + "wikipediaVecs/dictionary.file-0", - classOf[Text], - classOf[IntWritable]) - val documentFrequencyCount = sdc.sequenceFile(pathToData + "wikipediaVecs/df-count", - classOf[IntWritable], - classOf[LongWritable]) - - // setup the dictionary and document frequency count as maps - val dictionaryRDD = dictionary.map { - case (wKey, wVal) => wKey.asInstanceOf[Text] - .toString() -> wVal.get() - } - - val documentFrequencyCountRDD = documentFrequencyCount.map { - case (wKey, wVal) => wKey.asInstanceOf[IntWritable] - .get() -> wVal.get() - } - - val dictionaryMap = dictionaryRDD.collect.map(x => x._1.toString -> x._2.toInt).toMap - val dfCountMap = documentFrequencyCountRDD.collect.map(x => x._1.toInt -> x._2.toLong).toMap - -## Define a function to tokenize and vectorize new text using our current dictionary - -For this simple example, our function ```vectorizeDocument(...)``` will tokenize a new document into unigrams using native Java String methods and vectorize using our dictionary and document frequencies. You could also use a [Lucene](https://lucene.apache.org/core/) analyzer for bigrams, trigrams, etc., and integrate Apache [Tika](https://tika.apache.org/) to extract text from different document types (PDF, PPT, XLS, etc.). Here, however we will keep it simple, stripping and tokenizing our text using regexs and native String methods. - - def vectorizeDocument(document: String, - dictionaryMap: Map[String,Int], - dfMap: Map[Int,Long]): Vector = { - val wordCounts = document.replaceAll("[^\\p{L}\\p{Nd}]+", " ") - .toLowerCase - .split(" ") - .groupBy(identity) - .mapValues(_.length) - val vec = new RandomAccessSparseVector(dictionaryMap.size) - val totalDFSize = dfMap(-1) - val docSize = wordCounts.size - for (word <- wordCounts) { - val term = word._1 - if (dictionaryMap.contains(term)) { - val tfidf: TermWeight = new TFIDF() - val termFreq = word._2 - val dictIndex = dictionaryMap(term) - val docFreq = dfCountMap(dictIndex) - val currentTfIdf = tfidf.calculate(termFreq, - docFreq.toInt, - docSize, - totalDFSize.toInt) - vec.setQuick(dictIndex, currentTfIdf) - } - } - vec - } - -## Setup our classifier - - val labelMap = model.labelIndex - val numLabels = model.numLabels - val reverseLabelMap = labelMap.map(x => x._2 -> x._1) - - // instantiate the correct type of classifier - val classifier = model.isComplementary match { - case true => new ComplementaryNBClassifier(model) - case _ => new StandardNBClassifier(model) - } - -## Define an argmax function - -The label with the highest score wins the classification for a given document. - - def argmax(v: Vector): (Int, Double) = { - var bestIdx: Int = Integer.MIN_VALUE - var bestScore: Double = Integer.MIN_VALUE.asInstanceOf[Int].toDouble - for(i <- 0 until v.size) { - if(v(i) > bestScore){ - bestScore = v(i) - bestIdx = i - } - } - (bestIdx, bestScore) - } - -## Define our TF(-IDF) vector classifier - - def classifyDocument(clvec: Vector) : String = { - val cvec = classifier.classifyFull(clvec) - val (bestIdx, bestScore) = argmax(cvec) - reverseLabelMap(bestIdx) - } - -## Two sample news articles: United States Football and United Kingdom Football - - // A random United States football article - // http://www.reuters.com/article/2015/01/28/us-nfl-superbowl-security-idUSKBN0L12JR20150128 - val UStextToClassify = new String("(Reuters) - Super Bowl security officials acknowledge" + - " the NFL championship game represents a high profile target on a world stage but are" + - " unaware of any specific credible threats against Sunday's showcase. In advance of" + - " one of the world's biggest single day sporting events, Homeland Security Secretary" + - " Jeh Johnson was in Glendale on Wednesday to review security preparations and tour" + - " University of Phoenix Stadium where the Seattle Seahawks and New England Patriots" + - " will battle. Deadly shootings in Paris and arrest of suspects in Belgium, Greece and" + - " Germany heightened fears of more attacks around the world and social media accounts" + - " linked to Middle East militant groups have carried a number of threats to attack" + - " high-profile U.S. events. There is no specific credible threat, said Johnson, who" + - " has appointed a federal coordination team to work with local, state and federal" + - " agencies to ensure safety of fans, players and other workers associated with the" + - " Super Bowl. I'm confident we will have a safe and secure and successful event." + - " Sunday's game has been given a Special Event Assessment Rating (SEAR) 1 rating, the" + - " same as in previous years, except for the year after the Sept. 11, 2001 attacks, when" + - " a higher level was declared. But security will be tight and visible around Super" + - " Bowl-related events as well as during the game itself. All fans will pass through" + - " metal detectors and pat downs. Over 4,000 private security personnel will be deployed" + - " and the almost 3,000 member Phoenix police force will be on Super Bowl duty. Nuclear" + - " device sniffing teams will be deployed and a network of Bio-Watch detectors will be" + - " set up to provide a warning in the event of a biological attack. The Department of" + - " Homeland Security (DHS) said in a press release it had held special cyber-security" + - " and anti-sniper training sessions. A U.S. official said the Transportation Security" + - " Administration, which is responsible for screening airline passengers, will add" + - " screeners and checkpoint lanes at airports. Federal air marshals, behavior detection" + - " officers and dog teams will help to secure transportation systems in the area. We" + - " will be ramping it (security) up on Sunday, there is no doubt about that, said Federal"+ - " Coordinator Matthew Allen, the DHS point of contact for planning and support. I have" + - " every confidence the public safety agencies that represented in the planning process" + - " are going to have their best and brightest out there this weekend and we will have" + - " a very safe Super Bowl.") - - // A random United Kingdom football article - // http://www.reuters.com/article/2015/01/26/manchester-united-swissquote-idUSL6N0V52RZ20150126 - val UKtextToClassify = new String("(Reuters) - Manchester United have signed a sponsorship" + - " deal with online financial trading company Swissquote, expanding the commercial" + - " partnerships that have helped to make the English club one of the richest teams in" + - " world soccer. United did not give a value for the deal, the club's first in the sector," + - " but said on Monday it was a multi-year agreement. The Premier League club, 20 times" + - " English champions, claim to have 659 million followers around the globe, making the" + - " United name attractive to major brands like Chevrolet cars and sportswear group Adidas." + - " Swissquote said the global deal would allow it to use United's popularity in Asia to" + - " help it meet its targets for expansion in China. Among benefits from the deal," + - " Swissquote's clients will have a chance to meet United players and get behind the scenes" + - " at the Old Trafford stadium. Swissquote is a Geneva-based online trading company that" + - " allows retail investors to buy and sell foreign exchange, equities, bonds and other asset" + - " classes. Like other retail FX brokers, Swissquote was left nursing losses on the Swiss" + - " franc after Switzerland's central bank stunned markets this month by abandoning its cap" + - " on the currency. The fallout from the abrupt move put rival and West Ham United shirt" + - " sponsor Alpari UK into administration. Swissquote itself was forced to book a 25 million" + - " Swiss francs ($28 million) provision for its clients who were left out of pocket" + - " following the franc's surge. United's ability to grow revenues off the pitch has made" + - " them the second richest club in the world behind Spain's Real Madrid, despite a" + - " downturn in their playing fortunes. United Managing Director Richard Arnold said" + - " there was still lots of scope for United to develop sponsorships in other areas of" + - " business. The last quoted statistics that we had showed that of the top 25 sponsorship" + - " categories, we were only active in 15 of those, Arnold told Reuters. I think there is a" + - " huge potential still for the club, and the other thing we have seen is there is very" + - " significant growth even within categories. United have endured a tricky transition" + - " following the retirement of manager Alex Ferguson in 2013, finishing seventh in the" + - " Premier League last season and missing out on a place in the lucrative Champions League." + - " ($1 = 0.8910 Swiss francs) (Writing by Neil Maidment, additional reporting by Jemima" + - " Kelly; editing by Keith Weir)") - -## Vectorize and classify our documents - - val usVec = vectorizeDocument(UStextToClassify, dictionaryMap, dfCountMap) - val ukVec = vectorizeDocument(UKtextToClassify, dictionaryMap, dfCountMap) - - println("Classifying the news article about superbowl security (united states)") - classifyDocument(usVec) - - println("Classifying the news article about Manchester United (united kingdom)") - classifyDocument(ukVec) - -## Tie everything together in a new method to classify text - - def classifyText(txt: String): String = { - val v = vectorizeDocument(txt, dictionaryMap, dfCountMap) - classifyDocument(v) - } - -## Now we can simply call our classifyText(...) method on any String - - classifyText("Hello world from Queens") - classifyText("Hello world from London") - -## Model persistance - -You can save the model to HDFS: - - model.dfsWrite("/path/to/model") - -And retrieve it with: - - val model = NBModel.dfsRead("/path/to/model") - -The trained model can now be embedded in an external application. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/how-to-build-an-app.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/how-to-build-an-app.md b/website/docs/tutorials/how-to-build-an-app.md deleted file mode 100644 index 0ad232e..0000000 --- a/website/docs/tutorials/how-to-build-an-app.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -layout: page -title: Mahout Samsara In Core -theme: - name: mahout2 ---- -# How to create and App using Mahout - -This is an example of how to create a simple app using Mahout as a Library. The source is available on Github in the [3-input-cooc project](https://github.com/pferrel/3-input-cooc) with more explanation about what it does (has to do with collaborative filtering). For this tutorial we'll concentrate on the app rather than the data science. - -The app reads in three user-item interactions types and creats indicators for them using cooccurrence and cross-cooccurrence. The indicators will be written to text files in a format ready for search engine indexing in search engine based recommender. - -## Setup -In order to build and run the CooccurrenceDriver you need to install the following: - -* Install the Java 7 JDK from Oracle. Mac users look here: [Java SE Development Kit 7u72](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html). -* Install sbt (simple build tool) 0.13.x for [Mac](http://www.scala-sbt.org/release/tutorial/Installing-sbt-on-Mac.html), [Linux](http://www.scala-sbt.org/release/tutorial/Installing-sbt-on-Linux.html) or [manual instalation](http://www.scala-sbt.org/release/tutorial/Manual-Installation.html). -* Install [Spark 1.1.1](https://spark.apache.org/docs/1.1.1/spark-standalone.html). Don't forget to setup SPARK_HOME -* Install [Mahout 0.10.0](http://mahout.apache.org/general/downloads.html). Don't forget to setup MAHOUT_HOME and MAHOUT_LOCAL - -Why install if you are only using them as a library? Certain binaries and scripts are required by the libraries to get information about the environment like discovering where jars are located. - -Spark requires a set of jars on the classpath for the client side part of an app and another set of jars must be passed to the Spark Context for running distributed code. The example should discover all the neccessary classes automatically. - -## Application -Using Mahout as a library in an application will require a little Scala code. Scala has an App trait so we'll create an object, which inherits from ```App``` - - - object CooccurrenceDriver extends App { - } - - -This will look a little different than Java since ```App``` does delayed initialization, which causes the body to be executed when the App is launched, just as in Java you would create a main method. - -Before we can execute something on Spark we'll need to create a context. We could use raw Spark calls here but default values are setup for a Mahout context by using the Mahout helper function. - - implicit val mc = mahoutSparkContext(masterUrl = "local", - appName = "CooccurrenceDriver") - -We need to read in three files containing different interaction types. The files will each be read into a Mahout IndexedDataset. This allows us to preserve application-specific user and item IDs throughout the calculations. - -For example, here is data/purchase.csv: - - u1,iphone - u1,ipad - u2,nexus - u2,galaxy - u3,surface - u4,iphone - u4,galaxy - -Mahout has a helper function that reads the text delimited files SparkEngine.indexedDatasetDFSReadElements. The function reads single element tuples (user-id,item-id) in a distributed way to create the IndexedDataset. Distributed Row Matrices (DRM) and Vectors are important data types supplied by Mahout and IndexedDataset is like a very lightweight Dataframe in R, it wraps a DRM with HashBiMaps for row and column IDs. - -One important thing to note about this example is that we read in all datasets before we adjust the number of rows in them to match the total number of users in the data. This is so the math works out [(A'A, A'B, A'C)](http://mahout.apache.org/users/algorithms/intro-cooccurrence-spark.html) even if some users took one action but not another there must be the same number of rows in all matrices. - - /** - * Read files of element tuples and create IndexedDatasets one per action. These - * share a userID BiMap but have their own itemID BiMaps - */ - def readActions(actionInput: Array[(String, String)]): Array[(String, IndexedDataset)] = { - var actions = Array[(String, IndexedDataset)]() - - val userDictionary: BiMap[String, Int] = HashBiMap.create() - - // The first action named in the sequence is the "primary" action and - // begins to fill up the user dictionary - for ( actionDescription <- actionInput ) {// grab the path to actions - val action: IndexedDataset = SparkEngine.indexedDatasetDFSReadElements( - actionDescription._2, - schema = DefaultIndexedDatasetElementReadSchema, - existingRowIDs = userDictionary) - userDictionary.putAll(action.rowIDs) - // put the name in the tuple with the indexedDataset - actions = actions :+ (actionDescription._1, action) - } - - // After all actions are read in the userDictonary will contain every user seen, - // even if they may not have taken all actions . Now we adjust the row rank of - // all IndxedDataset's to have this number of rows - // Note: this is very important or the cooccurrence calc may fail - val numUsers = userDictionary.size() // one more than the cardinality - - val resizedNameActionPairs = actions.map { a => - //resize the matrix by, in effect by adding empty rows - val resizedMatrix = a._2.create(a._2.matrix, userDictionary, a._2.columnIDs).newRowCardinality(numUsers) - (a._1, resizedMatrix) // return the Tuple of (name, IndexedDataset) - } - resizedNameActionPairs // return the array of Tuples - } - - -Now that we have the data read in we can perform the cooccurrence calculation. - - // actions.map creates an array of just the IndeedDatasets - val indicatorMatrices = SimilarityAnalysis.cooccurrencesIDSs( - actions.map(a => a._2)) - -All we need to do now is write the indicators. - - // zip a pair of arrays into an array of pairs, reattaching the action names - val indicatorDescriptions = actions.map(a => a._1).zip(indicatorMatrices) - writeIndicators(indicatorDescriptions) - - -The ```writeIndicators``` method uses the default write function ```dfsWrite```. - - /** - * Write indicatorMatrices to the output dir in the default format - * for indexing by a search engine. - */ - def writeIndicators( indicators: Array[(String, IndexedDataset)]) = { - for (indicator <- indicators ) { - // create a name based on the type of indicator - val indicatorDir = OutputPath + indicator._1 - indicator._2.dfsWrite( - indicatorDir, - // Schema tells the writer to omit LLR strengths - // and format for search engine indexing - IndexedDatasetWriteBooleanSchema) - } - } - - -See the Github project for the full source. Now we create a build.sbt to build the example. - - name := "cooccurrence-driver" - - organization := "com.finderbots" - - version := "0.1" - - scalaVersion := "2.10.4" - - val sparkVersion = "1.1.1" - - libraryDependencies ++= Seq( - "log4j" % "log4j" % "1.2.17", - // Mahout's Spark code - "commons-io" % "commons-io" % "2.4", - "org.apache.mahout" % "mahout-math-scala_2.10" % "0.10.0", - "org.apache.mahout" % "mahout-spark_2.10" % "0.10.0", - "org.apache.mahout" % "mahout-math" % "0.10.0", - "org.apache.mahout" % "mahout-hdfs" % "0.10.0", - // Google collections, AKA Guava - "com.google.guava" % "guava" % "16.0") - - resolvers += "typesafe repo" at " http://repo.typesafe.com/typesafe/releases/" - - resolvers += Resolver.mavenLocal - - packSettings - - packMain := Map( - "cooc" -> "CooccurrenceDriver") - - -## Build -Building the examples from project's root folder: - - $ sbt pack - -This will automatically set up some launcher scripts for the driver. To run execute - - $ target/pack/bin/cooc - -The driver will execute in Spark standalone mode and put the data in /path/to/3-input-cooc/data/indicators/*indicator-type* - -## Using a Debugger -To build and run this example in a debugger like IntelliJ IDEA. Install from the IntelliJ site and add the Scala plugin. - -Open IDEA and go to the menu File->New->Project from existing sources->SBT->/path/to/3-input-cooc. This will create an IDEA project from ```build.sbt``` in the root directory. - -At this point you may create a "Debug Configuration" to run. In the menu choose Run->Edit Configurations. Under "Default" choose "Application". In the dialog hit the elipsis button "..." to the right of "Environment Variables" and fill in your versions of JAVA_HOME, SPARK_HOME, and MAHOUT_HOME. In configuration editor under "Use classpath from" choose root-3-input-cooc module. - -![image](http://mahout.apache.org/images/debug-config.png) - -Now choose "Application" in the left pane and hit the plus sign "+". give the config a name and hit the elipsis button to the right of the "Main class" field as shown. - -![image](http://mahout.apache.org/images/debug-config-2.png) - - -After setting breakpoints you are now ready to debug the configuration. Go to the Run->Debug... menu and pick your configuration. This will execute using a local standalone instance of Spark. - -##The Mahout Shell - -For small script-like apps you may wish to use the Mahout shell. It is a Scala REPL type interactive shell built on the Spark shell with Mahout-Samsara extensions. - -To make the CooccurrenceDriver.scala into a script make the following changes: - -* You won't need the context, since it is created when the shell is launched, comment that line out. -* Replace the logger.info lines with println -* Remove the package info since it's not needed, this will produce the file in ```path/to/3-input-cooc/bin/CooccurrenceDriver.mscala```. - -Note the extension ```.mscala``` to indicate we are using Mahout's scala extensions for math, otherwise known as [Mahout-Samsara](http://mahout.apache.org/users/environment/out-of-core-reference.html) - -To run the code make sure the output does not exist already - - $ rm -r /path/to/3-input-cooc/data/indicators - -Launch the Mahout + Spark shell: - - $ mahout spark-shell - -You'll see the Mahout splash: - - MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. - - _ _ - _ __ ___ __ _| |__ ___ _ _| |_ - | '_ ` _ \ / _` | '_ \ / _ \| | | | __| - | | | | | | (_| | | | | (_) | |_| | |_ - |_| |_| |_|\__,_|_| |_|\___/ \__,_|\__| version 0.10.0 - - - Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_72) - Type in expressions to have them evaluated. - Type :help for more information. - 15/04/26 09:30:48 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable - Created spark context.. - Mahout distributed context is available as "implicit val sdc". - mahout> - -To load the driver type: - - mahout> :load /path/to/3-input-cooc/bin/CooccurrenceDriver.mscala - Loading ./bin/CooccurrenceDriver.mscala... - import com.google.common.collect.{HashBiMap, BiMap} - import org.apache.log4j.Logger - import org.apache.mahout.math.cf.SimilarityAnalysis - import org.apache.mahout.math.indexeddataset._ - import org.apache.mahout.sparkbindings._ - import scala.collection.immutable.HashMap - defined module CooccurrenceDriver - mahout> - -To run the driver type: - - mahout> CooccurrenceDriver.main(args = Array("")) - -You'll get some stats printed: - - Total number of users for all actions = 5 - purchase indicator matrix: - Number of rows for matrix = 4 - Number of columns for matrix = 5 - Number of rows after resize = 5 - view indicator matrix: - Number of rows for matrix = 4 - Number of columns for matrix = 5 - Number of rows after resize = 5 - category indicator matrix: - Number of rows for matrix = 5 - Number of columns for matrix = 7 - Number of rows after resize = 5 - -If you look in ```path/to/3-input-cooc/data/indicators``` you should find folders containing the indicator matrices. http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/map-reduce/classification/bankmarketing-example.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/map-reduce/classification/bankmarketing-example.md b/website/docs/tutorials/map-reduce/classification/bankmarketing-example.md new file mode 100644 index 0000000..846a4ce --- /dev/null +++ b/website/docs/tutorials/map-reduce/classification/bankmarketing-example.md @@ -0,0 +1,53 @@ +--- +layout: default +title: +theme: + name: retro-mahout +--- + +Notice: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +#Bank Marketing Example + +### Introduction + +This page describes how to run Mahout's SGD classifier on the [UCI Bank Marketing dataset](http://mlr.cs.umass.edu/ml/datasets/Bank+Marketing). +The goal is to predict if the client will subscribe a term deposit offered via a phone call. The features in the dataset consist +of information such as age, job, marital status as well as information about the last contacts from the bank. + +### Code & Data + +The bank marketing example code lives under + +*mahout-examples/src/main/java/org.apache.mahout.classifier.sgd.bankmarketing* + +The data can be found at + +*mahout-examples/src/main/resources/bank-full.csv* + +### Code details + +This example consists of 3 classes: + + - BankMarketingClassificationMain + - TelephoneCall + - TelephoneCallParser + +When you run the main method of BankMarketingClassificationMain it parses the dataset using the TelephoneCallParser and trains +a logistic regression model with 20 runs and 20 passes. The TelephoneCallParser uses Mahout's feature vector encoder +to encode the features in the dataset into a vector. Afterwards the model is tested and the learning rate and AUC is printed accuracy is printed to standard output. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/map-reduce/classification/breiman-example.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/map-reduce/classification/breiman-example.md b/website/docs/tutorials/map-reduce/classification/breiman-example.md new file mode 100644 index 0000000..d8d049e --- /dev/null +++ b/website/docs/tutorials/map-reduce/classification/breiman-example.md @@ -0,0 +1,67 @@ +--- +layout: default +title: Breiman Example +theme: + name: retro-mahout +--- + +#Breiman Example + +#### Introduction + +This page describes how to run the Breiman example, which implements the test procedure described in [Leo Breiman's paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.23.3999&rep=rep1&type=pdf). The basic algorithm is as follows : + + * repeat *I* iterations + * in each iteration do + * keep 10% of the dataset apart as a testing set + * build two forests using the training set, one with *m = int(log2(M) + 1)* (called Random-Input) and one with *m = 1* (called Single-Input) + * choose the forest that gave the lowest oob error estimation to compute +the test set error + * compute the test set error using the Single Input Forest (test error), +this demonstrates that even with *m = 1*, Decision Forests give comparable +results to greater values of *m* + * compute the mean testset error using every tree of the chosen forest +(tree error). This should indicate how well a single Decision Tree performs + * compute the mean test error for all iterations + * compute the mean tree error for all iterations + + +#### Running the Example + +The current implementation is compatible with the [UCI repository](http://archive.ics.uci.edu/ml/) file format. We'll show how to run this example on two datasets: + +First, we deal with [Glass Identification](http://archive.ics.uci.edu/ml/datasets/Glass+Identification): download the [dataset](http://archive.ics.uci.edu/ml/machine-learning-databases/glass/glass.data) file called **glass.data** and store it onto your local machine. Next, we must generate the descriptor file **glass.info** for this dataset with the following command: + + bin/mahout org.apache.mahout.classifier.df.tools.Describe -p /path/to/glass.data -f /path/to/glass.info -d I 9 N L + +Substitute */path/to/* with the folder where you downloaded the dataset, the argument "I 9 N L" indicates the nature of the variables. Here it means 1 +ignored (I) attribute, followed by 9 numerical(N) attributes, followed by +the label (L). + +Finally, we build and evaluate our random forest classifier as follows: + + bin/mahout org.apache.mahout.classifier.df.BreimanExample -d /path/to/glass.data -ds /path/to/glass.info -i 10 -t 100 +which builds 100 trees (-t argument) and repeats the test 10 iterations (-i +argument) + +The example outputs the following results: + + * Selection error: mean test error for the selected forest on all iterations + * Single Input error: mean test error for the single input forest on all +iterations + * One Tree error: mean single tree error on all iterations + * Mean Random Input Time: mean build time for random input forests on all +iterations + * Mean Single Input Time: mean build time for single input forests on all +iterations + +We can repeat this for a [Sonar](http://archive.ics.uci.edu/ml/datasets/Connectionist+Bench+%28Sonar,+Mines+vs.+Rocks%29) usecase: download the [dataset](http://archive.ics.uci.edu/ml/machine-learning-databases/undocumented/connectionist-bench/sonar/sonar.all-data) file called **sonar.all-data** and store it onto your local machine. Generate the descriptor file **sonar.info** for this dataset with the following command: + + bin/mahout org.apache.mahout.classifier.df.tools.Describe -p /path/to/sonar.all-data -f /path/to/sonar.info -d 60 N L + +The argument "60 N L" means 60 numerical(N) attributes, followed by the label (L). Analogous to the previous case, we run the evaluation as follows: + + bin/mahout org.apache.mahout.classifier.df.BreimanExample -d /path/to/sonar.all-data -ds /path/to/sonar.info -i 10 -t 100 + + + http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/map-reduce/classification/twenty-newsgroups.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/map-reduce/classification/twenty-newsgroups.md b/website/docs/tutorials/map-reduce/classification/twenty-newsgroups.md new file mode 100644 index 0000000..472aaf6 --- /dev/null +++ b/website/docs/tutorials/map-reduce/classification/twenty-newsgroups.md @@ -0,0 +1,179 @@ +--- +layout: default +title: Twenty Newsgroups +theme: + name: retro-mahout +--- + + + +## Twenty Newsgroups Classification Example + + +## Introduction + +The 20 newsgroups dataset is a collection of approximately 20,000 +newsgroup documents, partitioned (nearly) evenly across 20 different +newsgroups. The 20 newsgroups collection has become a popular data set for +experiments in text applications of machine learning techniques, such as +text classification and text clustering. We will use the [Mahout CBayes](http://mahout.apache.org/users/mapreduce/classification/bayesian.html) +classifier to create a model that would classify a new document into one of +the 20 newsgroups. + + +### Prerequisites + +* Mahout has been downloaded ([instructions here](https://mahout.apache.org/general/downloads.html)) +* Maven is available +* Your environment has the following variables: + * **HADOOP_HOME** Environment variables refers to where Hadoop lives + * **MAHOUT_HOME** Environment variables refers to where Mahout lives + + +### Instructions for running the example + +1. If running Hadoop in cluster mode, start the hadoop daemons by executing the following commands: + + $ cd $HADOOP_HOME/bin + $ ./start-all.sh + + Otherwise: + + $ export MAHOUT_LOCAL=true + +2. In the trunk directory of Mahout, compile and install Mahout: + + $ cd $MAHOUT_HOME + $ mvn -DskipTests clean install + +3. Run the [20 newsgroups example script](https://github.com/apache/mahout/blob/master/examples/bin/classify-20newsgroups.sh) by executing: + + $ ./examples/bin/classify-20newsgroups.sh + +4. You will be prompted to select a classification method algorithm: + + 1. Complement Naive Bayes + 2. Naive Bayes + 3. Stochastic Gradient Descent + +Select 1 and the the script will perform the following: + +1. Create a working directory for the dataset and all input/output. +2. Download and extract the *20news-bydate.tar.gz* from the [20 newsgroups dataset](http://people.csail.mit.edu/jrennie/20Newsgroups/20news-bydate.tar.gz) to the working directory. +3. Convert the full 20 newsgroups dataset into a < Text, Text > SequenceFile. +4. Convert and preprocesses the dataset into a < Text, VectorWritable > SequenceFile containing term frequencies for each document. +5. Split the preprocessed dataset into training and testing sets. +6. Train the classifier. +7. Test the classifier. + + +Output should look something like: + + + ======================================================= + Confusion Matrix + ------------------------------------------------------- + a b c d e f g h i j k l m n o p q r s t <--Classified as + 381 0 0 0 0 9 1 0 0 0 1 0 0 2 0 1 0 0 3 0 |398 a=rec.motorcycles + 1 284 0 0 0 0 1 0 6 3 11 0 66 3 0 6 0 4 9 0 |395 b=comp.windows.x + 2 0 339 2 0 3 5 1 0 0 0 0 1 1 12 1 7 0 2 0 |376 c=talk.politics.mideast + 4 0 1 327 0 2 2 0 0 2 1 1 0 5 1 4 12 0 2 0 |364 d=talk.politics.guns + 7 0 4 32 27 7 7 2 0 12 0 0 6 0 100 9 7 31 0 0 |251 e=talk.religion.misc + 10 0 0 0 0 359 2 2 0 0 3 0 1 6 0 1 0 0 11 0 |396 f=rec.autos + 0 0 0 0 0 1 383 9 1 0 0 0 0 0 0 0 0 3 0 0 |397 g=rec.sport.baseball + 1 0 0 0 0 0 9 382 0 0 0 0 1 1 1 0 2 0 2 0 |399 h=rec.sport.hockey + 2 0 0 0 0 4 3 0 330 4 4 0 5 12 0 0 2 0 12 7 |385 i=comp.sys.mac.hardware + 0 3 0 0 0 0 1 0 0 368 0 0 10 4 1 3 2 0 2 0 |394 j=sci.space + 0 0 0 0 0 3 1 0 27 2 291 0 11 25 0 0 1 0 13 18|392 k=comp.sys.ibm.pc.hardware + 8 0 1 109 0 6 11 4 1 18 0 98 1 3 11 10 27 1 1 0 |310 l=talk.politics.misc + 0 11 0 0 0 3 6 0 10 6 11 0 299 13 0 2 13 0 7 8 |389 m=comp.graphics + 6 0 1 0 0 4 2 0 5 2 12 0 8 321 0 4 14 0 8 6 |393 n=sci.electronics + 2 0 0 0 0 0 4 1 0 3 1 0 3 1 372 6 0 2 1 2 |398 o=soc.religion.christian + 4 0 0 1 0 2 3 3 0 4 2 0 7 12 6 342 1 0 9 0 |396 p=sci.med + 0 1 0 1 0 1 4 0 3 0 1 0 8 4 0 2 369 0 1 1 |396 q=sci.crypt + 10 0 4 10 1 5 6 2 2 6 2 0 2 1 86 15 14 152 0 1 |319 r=alt.atheism + 4 0 0 0 0 9 1 1 8 1 12 0 3 0 2 0 0 0 341 2 |390 s=misc.forsale + 8 5 0 0 0 1 6 0 8 5 50 0 40 2 1 0 9 0 3 256|394 t=comp.os.ms-windows.misc + ======================================================= + Statistics + ------------------------------------------------------- + Kappa 0.8808 + Accuracy 90.8596% + Reliability 86.3632% + Reliability (standard deviation) 0.2131 + + + + + + +## End to end commands to build a CBayes model for 20 newsgroups +The [20 newsgroups example script](https://github.com/apache/mahout/blob/master/examples/bin/classify-20newsgroups.sh) issues the following commands as outlined above. We can build a CBayes classifier from the command line by following the process in the script: + +*Be sure that **MAHOUT_HOME**/bin and **HADOOP_HOME**/bin are in your **$PATH*** + +1. Create a working directory for the dataset and all input/output. + + $ export WORK_DIR=/tmp/mahout-work-${USER} + $ mkdir -p ${WORK_DIR} + +2. Download and extract the *20news-bydate.tar.gz* from the [20newsgroups dataset](http://people.csail.mit.edu/jrennie/20Newsgroups/20news-bydate.tar.gz) to the working directory. + + $ curl http://people.csail.mit.edu/jrennie/20Newsgroups/20news-bydate.tar.gz + -o ${WORK_DIR}/20news-bydate.tar.gz + $ mkdir -p ${WORK_DIR}/20news-bydate + $ cd ${WORK_DIR}/20news-bydate && tar xzf ../20news-bydate.tar.gz && cd .. && cd .. + $ mkdir ${WORK_DIR}/20news-all + $ cp -R ${WORK_DIR}/20news-bydate/*/* ${WORK_DIR}/20news-all + * If you're running on a Hadoop cluster: + + $ hadoop dfs -put ${WORK_DIR}/20news-all ${WORK_DIR}/20news-all + +3. Convert the full 20 newsgroups dataset into a < Text, Text > SequenceFile. + + $ mahout seqdirectory + -i ${WORK_DIR}/20news-all + -o ${WORK_DIR}/20news-seq + -ow + +4. Convert and preprocesses the dataset into a < Text, VectorWritable > SequenceFile containing term frequencies for each document. + + $ mahout seq2sparse + -i ${WORK_DIR}/20news-seq + -o ${WORK_DIR}/20news-vectors + -lnorm + -nv + -wt tfidf +If we wanted to use different parsing methods or transformations on the term frequency vectors we could supply different options here e.g.: -ng 2 for bigrams or -n 2 for L2 length normalization. See the [Creating vectors from text](http://mahout.apache.org/users/basics/creating-vectors-from-text.html) page for a list of all seq2sparse options. + +5. Split the preprocessed dataset into training and testing sets. + + $ mahout split + -i ${WORK_DIR}/20news-vectors/tfidf-vectors + --trainingOutput ${WORK_DIR}/20news-train-vectors + --testOutput ${WORK_DIR}/20news-test-vectors + --randomSelectionPct 40 + --overwrite --sequenceFiles -xm sequential + +6. Train the classifier. + + $ mahout trainnb + -i ${WORK_DIR}/20news-train-vectors + -el + -o ${WORK_DIR}/model + -li ${WORK_DIR}/labelindex + -ow + -c + +7. Test the classifier. + + $ mahout testnb + -i ${WORK_DIR}/20news-test-vectors + -m ${WORK_DIR}/model + -l ${WORK_DIR}/labelindex + -ow + -o ${WORK_DIR}/20news-testing + -c + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/map-reduce/classification/wikipedia-classifier-example.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/map-reduce/classification/wikipedia-classifier-example.md b/website/docs/tutorials/map-reduce/classification/wikipedia-classifier-example.md new file mode 100644 index 0000000..9df07da --- /dev/null +++ b/website/docs/tutorials/map-reduce/classification/wikipedia-classifier-example.md @@ -0,0 +1,57 @@ +--- +layout: default +title: Wikipedia XML parser and Naive Bayes Example +theme: + name: retro-mahout +--- +# Wikipedia XML parser and Naive Bayes Classifier Example + +## Introduction +Mahout has an [example script](https://github.com/apache/mahout/blob/master/examples/bin/classify-wikipedia.sh) [1] which will download a recent XML dump of the (entire if desired) [English Wikipedia database](http://dumps.wikimedia.org/enwiki/latest/). After running the classification script, you can use the [document classification script](https://github.com/apache/mahout/blob/master/examples/bin/spark-document-classifier.mscala) from the Mahout [spark-shell](http://mahout.apache.org/users/sparkbindings/play-with-shell.html) to vectorize and classify text from outside of the training and testing corpus using a modle built on the Wikipedia dataset. + +You can run this script to build and test a Naive Bayes classifier for option (1) 10 arbitrary countries or option (2) 2 countries (United States and United Kingdom). + +## Oververview + +Tou run the example simply execute the `$MAHOUT_HOME/examples/bin/classify-wikipedia.sh` script. + +By defult the script is set to run on a medium sized Wikipedia XML dump. To run on the full set (the entire english Wikipedia) you can change the download by commenting out line 78, and uncommenting line 80 of [classify-wikipedia.sh](https://github.com/apache/mahout/blob/master/examples/bin/classify-wikipedia.sh) [1]. However this is not recommended unless you have the resources to do so. *Be sure to clean your work directory when changing datasets- option (3).* + +The step by step process for Creating a Naive Bayes Classifier for the Wikipedia XML dump is very similar to that for [creating a 20 Newsgroups Classifier](http://mahout.apache.org/users/classification/twenty-newsgroups.html) [4]. The only difference being that instead of running `$mahout seqdirectory` on the unzipped 20 Newsgroups file, you'll run `$mahout seqwiki` on the unzipped Wikipedia xml dump. + + $ mahout seqwiki + +The above command launches `WikipediaToSequenceFile.java` which accepts a text file of categories [3] and starts an MR job to parse the each document in the XML file. This process will seek to extract documents with a wikipedia category tag which (exactly, if the `-exactMatchOnly` option is set) matches a line in the category file. If no match is found and the `-all` option is set, the document will be dumped into an "unknown" category. The documents will then be written out as a `` sequence file of the form (K:/category/document_title , V: document). + +There are 3 different example category files available to in the /examples/src/test/resources +directory: country.txt, country10.txt and country2.txt. You can edit these categories to extract a different corpus from the Wikipedia dataset. + +The CLI options for `seqwiki` are as follows: + + --input (-i) input pathname String + --output (-o) the output pathname String + --categories (-c) the file containing the Wikipedia categories + --exactMatchOnly (-e) if set, then the Wikipedia category must match + exactly instead of simply containing the category string + --all (-all) if set select all categories + --removeLabels (-rl) if set, remove [[Category:labels]] from document text after extracting label. + + +After `seqwiki`, the script runs `seq2sparse`, `split`, `trainnb` and `testnb` as in the [step by step 20newsgroups example](http://mahout.apache.org/users/classification/twenty-newsgroups.html). When all of the jobs have finished, a confusion matrix will be displayed. + +#Resourcese + +[1] [classify-wikipedia.sh](https://github.com/apache/mahout/blob/master/examples/bin/classify-wikipedia.sh) + +[2] [Document classification script for the Mahout Spark Shell](https://github.com/apache/mahout/blob/master/examples/bin/spark-document-classifier.mscala) + +[3] [Example category file](https://github.com/apache/mahout/blob/master/examples/src/test/resources/country10.txt) + +[4] [Step by step instructions for building a Naive Bayes classifier for 20newsgroups from the command line](http://mahout.apache.org/users/classification/twenty-newsgroups.html) + +[5] [Mahout MapReduce Naive Bayes](http://mahout.apache.org/users/classification/bayesian.html) + +[6] [Mahout Spark Naive Bayes](http://mahout.apache.org/users/algorithms/spark-naive-bayes.html) + +[7] [Mahout Scala Spark and H2O Bindings](http://mahout.apache.org/users/sparkbindings/home.html) + http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/map-reduce/index.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/map-reduce/index.md b/website/docs/tutorials/map-reduce/index.md new file mode 100644 index 0000000..691bb8b --- /dev/null +++ b/website/docs/tutorials/map-reduce/index.md @@ -0,0 +1,17 @@ +--- +layout: page +title: Deprecated Map Reduce Based Examples +theme: + name: mahout2 +--- + + +### Classification + +[Bank Marketing Example](classification/bankmarketing-example.html) + +[Breiman Exampe](classification/breiman-example.html) + +[Twenty Newsgroups](classification/twenty-newsgroups.html) + +[Wikipedia Classifier Example](classification/wikipedia-classifier-example.html) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/play-with-shell.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/play-with-shell.md b/website/docs/tutorials/play-with-shell.md deleted file mode 100644 index d193160..0000000 --- a/website/docs/tutorials/play-with-shell.md +++ /dev/null @@ -1,199 +0,0 @@ ---- -layout: page -title: Mahout Samsara In Core -theme: - name: mahout2 ---- -# Playing with Mahout's Spark Shell - -This tutorial will show you how to play with Mahout's scala DSL for linear algebra and its Spark shell. **Please keep in mind that this code is still in a very early experimental stage**. - -_(Edited for 0.10.2)_ - -## Intro - -We'll use an excerpt of a publicly available [dataset about cereals](http://lib.stat.cmu.edu/DASL/Datafiles/Cereals.html). The dataset tells the protein, fat, carbohydrate and sugars (in milligrams) contained in a set of cereals, as well as a customer rating for the cereals. Our aim for this example is to fit a linear model which infers the customer rating from the ingredients. - - -Name | protein | fat | carbo | sugars | rating -:-----------------------|:--------|:----|:------|:-------|:--------- -Apple Cinnamon Cheerios | 2 | 2 | 10.5 | 10 | 29.509541 -Cap'n'Crunch | 1 | 2 | 12 | 12 | 18.042851 -Cocoa Puffs | 1 | 1 | 12 | 13 | 22.736446 -Froot Loops | 2 | 1 | 11 | 13 | 32.207582 -Honey Graham Ohs | 1 | 2 | 12 | 11 | 21.871292 -Wheaties Honey Gold | 2 | 1 | 16 | 8 | 36.187559 -Cheerios | 6 | 2 | 17 | 1 | 50.764999 -Clusters | 3 | 2 | 13 | 7 | 40.400208 -Great Grains Pecan | 3 | 3 | 13 | 4 | 45.811716 - - -## Installing Mahout & Spark on your local machine - -We describe how to do a quick toy setup of Spark & Mahout on your local machine, so that you can run this example and play with the shell. - - 1. Download [Apache Spark 1.6.2](http://d3kbcqa49mib13.cloudfront.net/spark-1.6.2-bin-hadoop2.6.tgz) and unpack the archive file - 1. Change to the directory where you unpacked Spark and type ```sbt/sbt assembly``` to build it - 1. Create a directory for Mahout somewhere on your machine, change to there and checkout the master branch of Apache Mahout from GitHub ```git clone https://github.com/apache/mahout mahout``` - 1. Change to the ```mahout``` directory and build mahout using ```mvn -DskipTests clean install``` - -## Starting Mahout's Spark shell - - 1. Goto the directory where you unpacked Spark and type ```sbin/start-all.sh``` to locally start Spark - 1. Open a browser, point it to [http://localhost:8080/](http://localhost:8080/) to check whether Spark successfully started. Copy the url of the spark master at the top of the page (it starts with **spark://**) - 1. Define the following environment variables:
export MAHOUT_HOME=[directory into which you checked out Mahout]
-export SPARK_HOME=[directory where you unpacked Spark]
-export MASTER=[url of the Spark master]
-
- 1. Finally, change to the directory where you unpacked Mahout and type ```bin/mahout spark-shell```, -you should see the shell starting and get the prompt ```mahout> ```. Check -[FAQ](http://mahout.apache.org/users/sparkbindings/faq.html) for further troubleshooting. - -## Implementation - -We'll use the shell to interactively play with the data and incrementally implement a simple [linear regression](https://en.wikipedia.org/wiki/Linear_regression) algorithm. Let's first load the dataset. Usually, we wouldn't need Mahout unless we processed a large dataset stored in a distributed filesystem. But for the sake of this example, we'll use our tiny toy dataset and "pretend" it was too big to fit onto a single machine. - -*Note: You can incrementally follow the example by copy-and-pasting the code into your running Mahout shell.* - -Mahout's linear algebra DSL has an abstraction called *DistributedRowMatrix (DRM)* which models a matrix that is partitioned by rows and stored in the memory of a cluster of machines. We use ```dense()``` to create a dense in-memory matrix from our toy dataset and use ```drmParallelize``` to load it into the cluster, "mimicking" a large, partitioned dataset. - -
-val drmData = drmParallelize(dense(
-  (2, 2, 10.5, 10, 29.509541),  // Apple Cinnamon Cheerios
-  (1, 2, 12,   12, 18.042851),  // Cap'n'Crunch
-  (1, 1, 12,   13, 22.736446),  // Cocoa Puffs
-  (2, 1, 11,   13, 32.207582),  // Froot Loops
-  (1, 2, 12,   11, 21.871292),  // Honey Graham Ohs
-  (2, 1, 16,   8,  36.187559),  // Wheaties Honey Gold
-  (6, 2, 17,   1,  50.764999),  // Cheerios
-  (3, 2, 13,   7,  40.400208),  // Clusters
-  (3, 3, 13,   4,  45.811716)), // Great Grains Pecan
-  numPartitions = 2);
-
- -Have a look at this matrix. The first four columns represent the ingredients -(our features) and the last column (the rating) is the target variable for -our regression. [Linear regression](https://en.wikipedia.org/wiki/Linear_regression) -assumes that the **target variable** `\(\mathbf{y}\)` is generated by the -linear combination of **the feature matrix** `\(\mathbf{X}\)` with the -**parameter vector** `\(\boldsymbol{\beta}\)` plus the - **noise** `\(\boldsymbol{\varepsilon}\)`, summarized in the formula -`\(\mathbf{y}=\mathbf{X}\boldsymbol{\beta}+\boldsymbol{\varepsilon}\)`. -Our goal is to find an estimate of the parameter vector -`\(\boldsymbol{\beta}\)` that explains the data very well. - -As a first step, we extract `\(\mathbf{X}\)` and `\(\mathbf{y}\)` from our data matrix. We get *X* by slicing: we take all rows (denoted by ```::```) and the first four columns, which have the ingredients in milligrams as content. Note that the result is again a DRM. The shell will not execute this code yet, it saves the history of operations and defers the execution until we really access a result. **Mahout's DSL automatically optimizes and parallelizes all operations on DRMs and runs them on Apache Spark.** - -
-val drmX = drmData(::, 0 until 4)
-
- -Next, we extract the target variable vector *y*, the fifth column of the data matrix. We assume this one fits into our driver machine, so we fetch it into memory using ```collect```: - -
-val y = drmData.collect(::, 4)
-
- -Now we are ready to think about a mathematical way to estimate the parameter vector *β*. A simple textbook approach is [ordinary least squares (OLS)](https://en.wikipedia.org/wiki/Ordinary_least_squares), which minimizes the sum of residual squares between the true target variable and the prediction of the target variable. In OLS, there is even a closed form expression for estimating `\(\boldsymbol{\beta}\)` as -`\(\left(\mathbf{X}^{\top}\mathbf{X}\right)^{-1}\mathbf{X}^{\top}\mathbf{y}\)`. - -The first thing which we compute for this is `\(\mathbf{X}^{\top}\mathbf{X}\)`. The code for doing this in Mahout's scala DSL maps directly to the mathematical formula. The operation ```.t()``` transposes a matrix and analogous to R ```%*%``` denotes matrix multiplication. - -
-val drmXtX = drmX.t %*% drmX
-
- -The same is true for computing `\(\mathbf{X}^{\top}\mathbf{y}\)`. We can simply type the math in scala expressions into the shell. Here, *X* lives in the cluster, while is *y* in the memory of the driver, and the result is a DRM again. -
-val drmXty = drmX.t %*% y
-
- -We're nearly done. The next step we take is to fetch `\(\mathbf{X}^{\top}\mathbf{X}\)` and -`\(\mathbf{X}^{\top}\mathbf{y}\)` into the memory of our driver machine (we are targeting -features matrices that are tall and skinny , -so we can assume that `\(\mathbf{X}^{\top}\mathbf{X}\)` is small enough -to fit in). Then, we provide them to an in-memory solver (Mahout provides -the an analog to R's ```solve()``` for that) which computes ```beta```, our -OLS estimate of the parameter vector `\(\boldsymbol{\beta}\)`. - -
-val XtX = drmXtX.collect
-val Xty = drmXty.collect(::, 0)
-
-val beta = solve(XtX, Xty)
-
- -That's it! We have a implemented a distributed linear regression algorithm -on Apache Spark. I hope you agree that we didn't have to worry a lot about -parallelization and distributed systems. The goal of Mahout's linear algebra -DSL is to abstract away the ugliness of programming a distributed system -as much as possible, while still retaining decent performance and -scalability. - -We can now check how well our model fits its training data. -First, we multiply the feature matrix `\(\mathbf{X}\)` by our estimate of -`\(\boldsymbol{\beta}\)`. Then, we look at the difference (via L2-norm) of -the target variable `\(\mathbf{y}\)` to the fitted target variable: - -
-val yFitted = (drmX %*% beta).collect(::, 0)
-(y - yFitted).norm(2)
-
- -We hope that we could show that Mahout's shell allows people to interactively and incrementally write algorithms. We have entered a lot of individual commands, one-by-one, until we got the desired results. We can now refactor a little by wrapping our statements into easy-to-use functions. The definition of functions follows standard scala syntax. - -We put all the commands for ordinary least squares into a function ```ols```. - -
-def ols(drmX: DrmLike[Int], y: Vector) = 
-  solve(drmX.t %*% drmX, drmX.t %*% y)(::, 0)
-
-
- -Note that DSL declares implicit `collect` if coersion rules require an in-core argument. Hence, we can simply -skip explicit `collect`s. - -Next, we define a function ```goodnessOfFit``` that tells how well a model fits the target variable: - -
-def goodnessOfFit(drmX: DrmLike[Int], beta: Vector, y: Vector) = {
-  val fittedY = (drmX %*% beta).collect(::, 0)
-  (y - fittedY).norm(2)
-}
-
- -So far we have left out an important aspect of a standard linear regression -model. Usually there is a constant bias term added to the model. Without -that, our model always crosses through the origin and we only learn the -right angle. An easy way to add such a bias term to our model is to add a -column of ones to the feature matrix `\(\mathbf{X}\)`. -The corresponding weight in the parameter vector will then be the bias term. - -Here is how we add a bias column: - -
-val drmXwithBiasColumn = drmX cbind 1
-
- -Now we can give the newly created DRM ```drmXwithBiasColumn``` to our model fitting method ```ols``` and see how well the resulting model fits the training data with ```goodnessOfFit```. You should see a large improvement in the result. - -
-val betaWithBiasTerm = ols(drmXwithBiasColumn, y)
-goodnessOfFit(drmXwithBiasColumn, betaWithBiasTerm, y)
-
- -As a further optimization, we can make use of the DSL's caching functionality. We use ```drmXwithBiasColumn``` repeatedly as input to a computation, so it might be beneficial to cache it in memory. This is achieved by calling ```checkpoint()```. In the end, we remove it from the cache with uncache: - -
-val cachedDrmX = drmXwithBiasColumn.checkpoint()
-
-val betaWithBiasTerm = ols(cachedDrmX, y)
-val goodness = goodnessOfFit(cachedDrmX, betaWithBiasTerm, y)
-
-cachedDrmX.uncache()
-
-goodness
-
- - -Liked what you saw? Checkout Mahout's overview for the [Scala and Spark bindings](https://mahout.apache.org/users/sparkbindings/home.html). \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mahout/blob/c81fc8b7/website/docs/tutorials/playing-with-samsara-flink-batch.md ---------------------------------------------------------------------- diff --git a/website/docs/tutorials/playing-with-samsara-flink-batch.md b/website/docs/tutorials/playing-with-samsara-flink-batch.md new file mode 100644 index 0000000..4bbcd33 --- /dev/null +++ b/website/docs/tutorials/playing-with-samsara-flink-batch.md @@ -0,0 +1,111 @@ +--- +layout: default +title: +theme: + name: retro-mahout +--- + +## Getting Started + +To get started, add the following dependency to the pom: + + + org.apache.mahout + mahout-flink_2.10 + 0.12.0 + + +Here is how to use the Flink backend: + + import org.apache.flink.api.scala._ + import org.apache.mahout.math.drm._ + import org.apache.mahout.math.drm.RLikeDrmOps._ + import org.apache.mahout.flinkbindings._ + + object ReadCsvExample { + + def main(args: Array[String]): Unit = { + val filePath = "path/to/the/input/file" + + val env = ExecutionEnvironment.getExecutionEnvironment + implicit val ctx = new FlinkDistributedContext(env) + + val drm = readCsv(filePath, delim = "\t", comment = "#") + val C = drm.t %*% drm + println(C.collect) + } + + } + +## Current Status + +The top JIRA for Flink backend is [MAHOUT-1570](https://issues.apache.org/jira/browse/MAHOUT-1570) which has been fully implemented. + +### Implemented + +* [MAHOUT-1701](https://issues.apache.org/jira/browse/MAHOUT-1701) Mahout DSL for Flink: implement AtB ABt and AtA operators +* [MAHOUT-1702](https://issues.apache.org/jira/browse/MAHOUT-1702) implement element-wise operators (like `A + 2` or `A + B`) +* [MAHOUT-1703](https://issues.apache.org/jira/browse/MAHOUT-1703) implement `cbind` and `rbind` +* [MAHOUT-1709](https://issues.apache.org/jira/browse/MAHOUT-1709) implement slicing (like `A(1 to 10, ::)`) +* [MAHOUT-1710](https://issues.apache.org/jira/browse/MAHOUT-1710) implement right in-core matrix multiplication (`A %*% B` when `B` is in-core) +* [MAHOUT-1711](https://issues.apache.org/jira/browse/MAHOUT-1711) implement broadcasting +* [MAHOUT-1712](https://issues.apache.org/jira/browse/MAHOUT-1712) implement operators `At`, `Ax`, `Atx` - `Ax` and `At` are implemented +* [MAHOUT-1734](https://issues.apache.org/jira/browse/MAHOUT-1734) implement I/O - should be able to read results of Flink bindings +* [MAHOUT-1747](https://issues.apache.org/jira/browse/MAHOUT-1747) add support for different types of indexes (String, long, etc) - now supports `Int`, `Long` and `String` +* [MAHOUT-1748](https://issues.apache.org/jira/browse/MAHOUT-1748) switch to Flink Scala API +* [MAHOUT-1749](https://issues.apache.org/jira/browse/MAHOUT-1749) Implement `Atx` +* [MAHOUT-1750](https://issues.apache.org/jira/browse/MAHOUT-1750) Implement `ABt` +* [MAHOUT-1751](https://issues.apache.org/jira/browse/MAHOUT-1751) Implement `AtA` +* [MAHOUT-1755](https://issues.apache.org/jira/browse/MAHOUT-1755) Flush intermediate results to FS - Flink, unlike Spark, does not store intermediate results in memory. +* [MAHOUT-1764](https://issues.apache.org/jira/browse/MAHOUT-1764) Add standard backend tests for Flink +* [MAHOUT-1765](https://issues.apache.org/jira/browse/MAHOUT-1765) Add documentation about Flink backend +* [MAHOUT-1776](https://issues.apache.org/jira/browse/MAHOUT-1776) Refactor common Engine agnostic classes to Math-Scala module +* [MAHOUT-1777](https://issues.apache.org/jira/browse/MAHOUT-1777) move HDFSUtil classes into the HDFS module +* [MAHOUT-1804](https://issues.apache.org/jira/browse/MAHOUT-1804) Implement drmParallelizeWithRowLabels(..) in Flink +* [MAHOUT-1805](https://issues.apache.org/jira/browse/MAHOUT-1805) Implement allReduceBlock(..) in Flink bindings +* [MAHOUT-1809](https://issues.apache.org/jira/browse/MAHOUT-1809) Failing tests in flin-bindings: dals and dspca +* [MAHOUT-1810](https://issues.apache.org/jira/browse/MAHOUT-1810) Failing test in flink-bindings: A + B Identically partitioned (mapBlock Checkpointing issue) +* [MAHOUT-1812](https://issues.apache.org/jira/browse/MAHOUT-1812) Implement drmParallelizeWithEmptyLong(..) in flink bindings +* [MAHOUT-1814](https://issues.apache.org/jira/browse/MAHOUT-1814) Implement drm2intKeyed in flink bindings +* [MAHOUT-1815](https://issues.apache.org/jira/browse/MAHOUT-1815) dsqDist(X,Y) and dsqDist(X) failing in flink tests +* [MAHOUT-1816](https://issues.apache.org/jira/browse/MAHOUT-1816) Implement newRowCardinality in CheckpointedFlinkDrm +* [MAHOUT-1817](https://issues.apache.org/jira/browse/MAHOUT-1817) Implement caching in Flink Bindings +* [MAHOUT-1818](https://issues.apache.org/jira/browse/MAHOUT-1818) dals test failing in Flink Bindings +* [MAHOUT-1819](https://issues.apache.org/jira/browse/MAHOUT-1819) Set the default Parallelism for Flink execution in FlinkDistributedContext +* [MAHOUT-1820](https://issues.apache.org/jira/browse/MAHOUT-1820) Add a method to generate Tuple> to support Flink backend +* [MAHOUT-1821](https://issues.apache.org/jira/browse/MAHOUT-1821) Use a mahout-flink-conf.yaml configuration file for Mahout specific Flink configuration +* [MAHOUT-1822](https://issues.apache.org/jira/browse/MAHOUT-1822) Update NOTICE.txt, License.txt to add Apache Flink +* [MAHOUT-1823](https://issues.apache.org/jira/browse/MAHOUT-1823) Modify MahoutFlinkTestSuite to implement FlinkTestBase +* [MAHOUT-1824](https://issues.apache.org/jira/browse/MAHOUT-1824) Optimize FlinkOpAtA to use upper triangular matrices +* [MAHOUT-1825](https://issues.apache.org/jira/browse/MAHOUT-1825) Add List of Flink algorithms to Mahout wiki page + +### Tests + +There is a set of standard tests that all engines should pass (see [MAHOUT-1764](https://issues.apache.org/jira/browse/MAHOUT-1764)). + +* `DistributedDecompositionsSuite` +* `DrmLikeOpsSuite` +* `DrmLikeSuite` +* `RLikeDrmOpsSuite` + + +These are Flink-backend specific tests, e.g. + +* `DrmLikeOpsSuite` for operations like `norm`, `rowSums`, `rowMeans` +* `RLikeOpsSuite` for basic LA like `A.t %*% A`, `A.t %*% x`, etc +* `LATestSuite` tests for specific operators like `AtB`, `Ax`, etc +* `UseCasesSuite` has more complex examples, like power iteration, ridge regression, etc + +## Environment + +For development the minimal supported configuration is + +* [JDK 1.7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) +* [Scala 2.10] + +When using mahout, please import the following modules: + +* `mahout-math` +* `mahout-math-scala` +* `mahout-flink_2.10` +* \ No newline at end of file