Skip to Content
Machine Learning in Java - Second Edition
book

Machine Learning in Java - Second Edition

by AshishSingh Bhatia, Bostjan Kaluza
November 2018
Intermediate to advanced
300 pages
7h 42m
English
Packt Publishing
Content preview from Machine Learning in Java - Second Edition

Content-based filtering

Content-based filtering is out of the scope of the Mahout framework, mainly because it is up to you to decide how to define similar items. If we want to do a content-based item similarity, we need to implement our own ItemSimilarity. For instance, in our book's dataset, we might want to make up the following rule for book similarity:

  • If the genres are the same, add 0.15 to similarity
  • If the author is the same, add 0.50 to similarity

We can now implement our own similarity measure, as follows:

class MyItemSimilarity implements ItemSimilarity { ... public double itemSimilarity(long itemID1, long itemID2) { MyBook book1 = lookupMyBook (itemID1); MyBook book2 = lookupMyBook (itemID2); double similarity = 0.0; if (book1.getGenre().equals(book2.getGenre()) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Java Machine Learning

Mastering Java Machine Learning

Uday Kamath, Krishna Choppella
Java: Data Science Made Easy

Java: Data Science Made Easy

Richard M. Reese, Jennifer L. Reese, Alexey Grigorev

Publisher Resources

ISBN: 9781788474399Supplemental Content