(Quick Reference)

3 Configuration - Reference Documentation

Authors: Lim Chee Kin

Version: 0.5.2

3 Configuration

The plugin support both the file data model and MySQL data model.

For file data model, no additional configuration is required to make use of command line tool of the plugin, but the data file must be located in classpath such as grails-app/conf and data file name must be specified in mahout.recommender.data.file for web-based tools such as recommenders' evaluator and recommender.

For MySQL data model, change mahout.recommender.data.model from 'file' to 'mysql' and configure the DataSource.groovy properly.

3.1 Basic Configuration

The following table described configuration items in Config.groovy supported by the plugin:
  • Item 10 to 21 below only applicable when mahout.recommender.data.model = 'mysql'
  • MahoutRecommenderConstants = org.grails.mahout.recommender.MahoutRecommenderConstants
  • AbstractJDBCDataModel = org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
  • AbstractJDBCDiffStorage = org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage

No.Configuration ItemDescription
1.mahout.recommender.modeSpecify mode to determine recommender to be used. Default value is 'input' specified in MahoutRecommenderConstants.DEFAULT_MODE. Valid values: 'input', 'config' or 'class'. In 'input' mode, user need to specify value for item 5 to 9 below on screen. In 'config' mode, it will take values configured in item 5 to 9 below. In 'class' mode, it will take value specified in mahout.recommender.builderClass.
2.mahout.recommender.data.modelSpecify which data model to be used. Default value is 'file' specified in MahoutRecommenderConstants.DEFAULT_DATA_MODEL. Valid values: 'file' or 'mysql'. When the value is 'file'data file name must be specified in mahout.recommender.data.file for web-based tools such as recommenders' evaluator and recommender.
3.mahout.recommender.data.fileData file to be loaded by FileDataModel. Default value is 'data.csv' specified in MahoutRecommenderConstants.DEFAULT_DATA_FILE. The data file specified must me located in classpath such as grails-app/config.
4.mahout.recommender.builderClassRecommender to be loaded when mahout.recommender.mode is 'class'. Value specified must be full class name of the class that implements org.apache.mahout.cf.taste.eval.RecommenderBuilder such as 'mia.recommender.ch05.LibimsetiRecommenderBuilder'.
5.mahout.recommender.hasPreferenceSpecify "has preference value" when mahout.recommender.mode is 'config'. Valid values: true or false.
6.mahout.recommender.selectedSpecify recommender when mahout.recommender.mode is 'config'. Valid values: 1, 2 or 3 (1. user-based, 2. item-based or 3. slope-one).
7.mahout.recommender.similaritySpecify similarity metric when mahout.recommender.mode is 'config'. Valid values: 'PearsonCorrelation', 'EuclideanDistance', 'LogLikelihood' or 'TanimotoCoefficient'.
8.mahout.recommender.withWeightingSpecify whether weighting is enabled when mahout.recommender.mode is 'config'. Valid values: true or false. Applicable to 'PearsonCorrelation' or 'EuclideanDistance' similarity metric or Slope-one recommender only.
9.mahout.recommender.neighborhoodSpecify whether fix-size neighborhood or threshold-based neighborhood to be used when mahout.recommender.mode is 'config' and user-based recommender is selected. Integer value for fix-size neighborhood such as 4 and decimal value (< 1.0) for threshold-based neighborhood such as 0.5.
10.mahout.recommender.preference.tableOverwrite default value 'taste_preferences' specified in AbstractJDBCDataModel.DEFAULT_PREFERENCE_TABLE.
11.mahout.recommender.preference.userIdColumnOverwrite default value 'user_id' specified in AbstractJDBCDataModel.DEFAULT_USER_ID_COLUMN.
12.mahout.recommender.preference.itemIdColumnOverwrite default value 'item_id' specified in AbstractJDBCDataModel.DEFAULT_ITEM_ID_COLUMN.
13.mahout.recommender.preference.valueColumnOverwrite default value 'preference' specified in AbstractJDBCDataModel.DEFAULT_PREFERENCE_COLUMN.
14.mahout.recommender.preference.timestampColumnOverwrite default value 'last_updated' specified in MahoutRecommenderConstants.DEFAULT_PREFERENCE_TIME_COLUMN.
15.mahout.recommender.slopeone.diffs.tableOverwrite default value 'taste_slopeone_diffs' specified in AbstractJDBCDiffStorage.DEFAULT_DIFF_TABLE.
16.mahout.recommender.slopeone.diffs.itemIDAColumnOverwrite default value 'item_id_a' specified in AbstractJDBCDiffStorage.DEFAULT_ITEM_A_COLUMN.
17.mahout.recommender.slopeone.diffs.itemIDBColumnOverwrite default value 'item_id_b' specified in AbstractJDBCDiffStorage.DEFAULT_ITEM_B_COLUMN.
18.mahout.recommender.slopeone.diffs.countColumnOverwrite default value 'count' specified in AbstractJDBCDiffStorage.DEFAULT_COUNT_COLUMN.
19.mahout.recommender.slopeone.diffs.avgColumnOverwrite default value 'average_diff' specified in AbstractJDBCDiffStorage.DEFAULT_AVERAGE_DIFF_COLUMN.
20.mahout.recommender.slopeone.diffs.stdevColumnOverwrite default value 'standard_deviation' specified in AbstractJDBCDiffStorage.DEFAULT_STDEV_COLUMN.
21.mahout.recommender.slopeone.diffs.minDiffCountOverwrite default value 2 specified in MahoutRecommenderConstants.DEFAULT_SLOPEONE_DIFFS_MIN_COUNT.
22.mahout.recommender.evaluator.trainingPercentageOverwrite default value 0.7 specified in MahoutRecommenderConstants.DEFAULT_TRAINING_PERCENTAGE.
23.mahout.recommender.evaluator.evaluationPercentageOverwrite default value 1.0 specified in MahoutRecommenderConstants.DEFAULT_EVALUATION_PERCENTAGE.

3.2 The MySQL Data Model

The plugin is using file data model by default, this section will described step-by-step of how to setup your project to use MySQL data model with assumption that MySQL database is pre-installed and started in your development workstation.

Steps to setup Mahout Recommendation Plugin with MySQL database

Create Recommender Database in MySQL

  • Login to MySQL using command below:

mysql -u root
  • Create recommender database using command below:

create database recommender

Download and Setup MySQL Connector/J (JDBC Driver)

  • Download latest MySQL Connector/J at http://www.mysql.com/downloads/connector/j/.
  • Extract the downloaded compressed file and copy the mysql-connector-java-5.1.x-bin.jar to lib directory of your grails application.

Update Config.groovy

  • Update mahout.recommender.data.model in grails-app/conf/Config.groovy from 'file' to 'mysql', for example:

mahout.recommender.data.model = 'mysql'  // 'file' or 'mysql'

Update Datasource.groovy

  • Update database configurations in grails-app/conf/DataSource.groovy from HSQL or H2 to MySQL, for example:

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    username = "root"
    password = ""
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop','update'
            url = "jdbc:mysql://localhost:3306/recommender"
    test {
        dataSource {
            dbCreate = "create-drop"          
            url = "jdbc:mysql://localhost:3306/recommender"
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:mysql://localhost:3306/recommender"

To save your typing, you can download the MySQL's DataSource.groovy.

Done! You should able run your mahout recommender application with MySQL data model without any problem.