Example usage for org.apache.mahout.cf.taste.hadoop.item AggregateAndRecommendReducer DEFAULT_NUM_RECOMMENDATIONS

List of usage examples for org.apache.mahout.cf.taste.hadoop.item AggregateAndRecommendReducer DEFAULT_NUM_RECOMMENDATIONS

Introduction

In this page you can find the example usage for org.apache.mahout.cf.taste.hadoop.item AggregateAndRecommendReducer DEFAULT_NUM_RECOMMENDATIONS.

Prototype

int DEFAULT_NUM_RECOMMENDATIONS

To view the source code for org.apache.mahout.cf.taste.hadoop.item AggregateAndRecommendReducer DEFAULT_NUM_RECOMMENDATIONS.

Click Source Link

Usage

From source file:hadoop.api.RecommenderJob.java

License:Apache License

/**
 * Get the args and set the Option/* w w w.  j a  v  a2  s  .co  m*/
 *
 * @param args Information about the input path, output path, booleanData, and similarity
 * @return Number of Recommendations
 * @throws IOException
 */
public int prepareRecommender(String[] args) throws IOException {
    addInputOption();
    addOutputOption();
    addOption("numRecommendations", "n", "Number of recommendations per user",
            String.valueOf(hadoop.api.AggregateAndRecommendReducer.DEFAULT_NUM_RECOMMENDATIONS));
    addOption("usersFile", null, "File of users to recommend for", null);
    addOption("itemsFile", null, "File of items to recommend for", null);
    addOption("filterFile", "f",
            "File containing comma-separated userID,itemID pairs. Used to exclude the item from "
                    + "the recommendations for that user (optional)",
            null);
    addOption("booleanData", "b", "Treat input as without pref values", Boolean.FALSE.toString());
    addOption("maxPrefsPerUser", "mxp",
            "Maximum number of preferences considered per user in final recommendation phase",
            String.valueOf(UserVectorSplitterMapper.DEFAULT_MAX_PREFS_PER_USER_CONSIDERED));
    addOption("minPrefsPerUser", "mp",
            "ignore users with less preferences than this in the similarity computation " + "(default: "
                    + DEFAULT_MIN_PREFS_PER_USER + ')',
            String.valueOf(DEFAULT_MIN_PREFS_PER_USER));
    addOption("maxSimilaritiesPerItem", "m", "Maximum number of similarities considered per item ",
            String.valueOf(DEFAULT_MAX_SIMILARITIES_PER_ITEM));
    addOption("maxPrefsInItemSimilarity", "mpiis",
            "max number of preferences to consider per user or item in the "
                    + "item similarity computation phase, users or items with more preferences will be sampled down (default: "
                    + DEFAULT_MAX_PREFS + ')',
            String.valueOf(DEFAULT_MAX_PREFS));
    addOption("similarityClassname", "s", "Name of distributed similarity measures class to instantiate, "
            + "alternatively use one of the predefined similarities (" + VectorSimilarityMeasures.list() + ')',
            true);
    addOption("threshold", "tr", "discard item pairs with a similarity value below this", false);
    addOption("outputPathForSimilarityMatrix", "opfsm",
            "write the item similarity matrix to this path (optional)", false);
    addOption("randomSeed", null, "use this seed for sampling", false);
    //addOption("outputType", "ot", "Output Type", "TextOutputFormat");
    addFlag("sequencefileOutput", null, "write the output into a SequenceFile instead of a text file");

    parsedArgs = parseArguments(args);
    if (parsedArgs == null) {
        return -1;
    }

    int numRecommendations = Integer.parseInt(getOption("numRecommendations"));

    Path explicitFilterPath = getTempPath("explicitFilterPath");

    return numRecommendations;
}