Book Image

Clojure for Data Science

By : Henry Garner
Book Image

Clojure for Data Science

By: Henry Garner

Overview of this book

Table of Contents (18 chapters)
Clojure for Data Science
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Recommender evaluation with Mahout


Mahout provides a set of classes to help with the task of evaluating our recommender. Like the cross-validation we performed with the clj-ml library in Chapter 4, Classification, Mahout's evaluation proceeds by splitting the our ratings into two sets: a test set and a training set.

By training our recommender on the training set and then evaluating its performance on the test set, we can gain an understanding of how well, or poorly, our algorithm is performing against real data. To handle the task of training a model on the training data provided by Mahout's evaluator, we must supply an object conforming to the RecommenderBuilder interface. The interface defines just one method: buildRecommender. We can create an anonymous RecommenderBuilder type using reify:

(defn recommender-builder [sim n]
  (reify RecommenderBuilder
    (buildRecommender [this model]
      (let [nhood (NearestNUserNeighborhood. n sim model)]
        (GenericUserBasedRecommender. model...