Package org.apache.mahout.cf.taste.impl.model.file

Examples of org.apache.mahout.cf.taste.impl.model.file.FileDataModel


  @Override
  protected void setup(Context context) {
    Configuration jobConf = context.getConfiguration();
    String dataModelFile = jobConf.get(DATA_MODEL_FILE);
    String recommenderClassName = jobConf.get(RECOMMENDER_CLASS_NAME);
    FileDataModel fileDataModel;
    try {
      Path dataModelPath = new Path(dataModelFile);
      FileSystem fs = FileSystem.get(dataModelPath.toUri(), jobConf);
      File tempDataFile = File.createTempFile("mahout-taste-hadoop", "txt");
      tempDataFile.deleteOnExit();
      fs.copyToLocalFile(dataModelPath, new Path(tempDataFile.getAbsolutePath()));
      fileDataModel = new FileDataModel(tempDataFile);
    } catch (IOException ioe) {
      throw new IllegalStateException(ioe);
    }
    try {
      Class<? extends Recommender> recommenderClass = Class.forName(recommenderClassName).asSubclass(
View Full Code Here


  private LoadEvaluationRunner() {
  }

  public static void main(String[] args) throws Exception {

    DataModel model = new FileDataModel(new File(args[0]));

    int howMany = 10;
    if (args.length > 1) {
      howMany = Integer.parseInt(args[1]);
    }
View Full Code Here

  @Override
  public void configure(JobConf jobConf) {
    String dataModelFile = jobConf.get(DATA_MODEL_FILE);
    String recommenderClassName = jobConf.get(RECOMMENDER_CLASS_NAME);
    FileDataModel fileDataModel;
    try {
      FileSystem fs = FileSystem.get(jobConf);
      File tempDataFile = File.createTempFile("mahout-taste-hadoop", "txt");
      tempDataFile.deleteOnExit();
      fs.copyToLocalFile(new Path(dataModelFile), new Path(tempDataFile.getAbsolutePath()));
      fileDataModel = new FileDataModel(tempDataFile);
    } catch (IOException ioe) {
      throw new RuntimeException(ioe);
    }
    try {
      Class<? extends Recommender> recommenderClass = Class.forName(recommenderClassName).asSubclass(Recommender.class);
View Full Code Here

    Path dataModelPath = new Path(dataModelFile);
    FileSystem fs = FileSystem.get(dataModelPath.toUri(), jobConf);
    File tempDataFile = File.createTempFile("mahout-taste-hadoop", "txt");
    tempDataFile.deleteOnExit();
    fs.copyToLocalFile(dataModelPath, new Path(tempDataFile.getAbsolutePath()));
    FileDataModel fileDataModel = new FileDataModel(tempDataFile);

    try {
      Class<? extends Recommender> recommenderClass = Class.forName(recommenderClassName).asSubclass(
        Recommender.class);
      Constructor<? extends Recommender> constructor = recommenderClass.getConstructor(DataModel.class);
View Full Code Here

  private LoadEvaluationRunner() {
  }

  public static void main(String[] args) throws Exception {

    DataModel model = new FileDataModel(new File(args[0]));

    int howMany = 10;
    if (args.length > 1) {
      howMany = Integer.parseInt(args[1]);
    }
View Full Code Here

  @Override
  protected void setup(Context context) {
    Configuration jobConf = context.getConfiguration();
    String dataModelFile = jobConf.get(DATA_MODEL_FILE);
    String recommenderClassName = jobConf.get(RECOMMENDER_CLASS_NAME);
    FileDataModel fileDataModel;
    try {
      Path dataModelPath = new Path(dataModelFile);
      FileSystem fs = FileSystem.get(dataModelPath.toUri(), jobConf);
      File tempDataFile = File.createTempFile("mahout-taste-hadoop", "txt");
      tempDataFile.deleteOnExit();
      fs.copyToLocalFile(dataModelPath, new Path(tempDataFile.getAbsolutePath()));
      fileDataModel = new FileDataModel(tempDataFile);
    } catch (IOException ioe) {
      throw new IllegalStateException(ioe);
    }
    try {
      Class<? extends Recommender> recommenderClass =
View Full Code Here

    Path dataModelPath = new Path(dataModelFile);
    FileSystem fs = FileSystem.get(dataModelPath.toUri(), jobConf);
    File tempDataFile = File.createTempFile("mahout-taste-hadoop", "txt");
    tempDataFile.deleteOnExit();
    fs.copyToLocalFile(dataModelPath, new Path(tempDataFile.getAbsolutePath()));
    FileDataModel fileDataModel = new FileDataModel(tempDataFile);

    try {
      Class<? extends Recommender> recommenderClass = Class.forName(recommenderClassName).asSubclass(
        Recommender.class);
      Constructor<? extends Recommender> constructor = recommenderClass.getConstructor(DataModel.class);
View Full Code Here

    predictor.setConf(conf);
    predictor.run(new String[] { "--output", outputDir.getAbsolutePath(), "--pairs", pairs.getAbsolutePath(),
        "--userFeatures", userFeatures.getAbsolutePath(), "--itemFeatures", itemFeatures.getAbsolutePath(),
        "--tempDir", tempDir.getAbsolutePath() });

    FileDataModel dataModel = new FileDataModel(new File(outputDir, "part-r-00000"));
    assertEquals(3, dataModel.getNumUsers());
    assertEquals(2, dataModel.getNumItems());
    assertEquals(2.45f, dataModel.getPreferenceValue(0, 0), EPSILON);
    assertEquals(-6.6f, dataModel.getPreferenceValue(2, 1), EPSILON);
    assertEquals(-0.61f, dataModel.getPreferenceValue(1, 0), EPSILON);
  }
View Full Code Here

    }
  }

  private static void recommend(String ratingsFile, int ... userIds)
      throws TasteException, IOException {
    DataModel model = new FileDataModel(new File(ratingsFile));

    UserSimilarity similarity = new PearsonCorrelationSimilarity(model);

    UserNeighborhood neighborhood =
        new NearestNUserNeighborhood(
View Full Code Here

    }
  }

  public static void evaluate(String ratingsFile)
      throws TasteException, IOException {
    DataModel model = new FileDataModel(new File(ratingsFile));
    RecommenderEvaluator evaluator =
        new AverageAbsoluteDifferenceRecommenderEvaluator();
    RecommenderBuilder recommenderBuilder = new MyRecommendBuilder();
    evaluator.evaluate(
        recommenderBuilder,
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.model.file.FileDataModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.