Package com.chine.kmeans.models

Examples of com.chine.kmeans.models.Movie


    SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
   
    Text key = new Text();
    Text value = new Text();
    while(reader.next(key, value)) {
      Movie currentMovie = new Movie(Integer.valueOf(key.toString())
          , value.toString());
      if(currentMovie.getMap().size() > 5)
        canopyCenters.add(currentMovie);
    }
  }
View Full Code Here


    SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
   
    Text key = new Text();
    Text value = new Text();
    while(reader.next(key, value)) {
      Movie currentMovie = new Movie(Integer.valueOf(key.toString())
          , value.toString());
      if(currentMovie.getMap().size() > 5)
        kmeansCenters.add(currentMovie);
    }
  }
View Full Code Here

    throws IOException, InterruptedException {
   
    String[] splits = value.toString().split(":");
    int movieId = Integer.valueOf(splits[splits.length-2]);
    String data = splits[splits.length-1];
    Movie currentMovie = new Movie(movieId, data);
   
    HashSet<Movie> hasCalcCenters = new HashSet<Movie>();
    double maxDst = -1;
    Movie maxMovie = null;
   
    for(int i=0; i<splits.length-2; i++) {
      Integer cId = Integer.valueOf(splits[i]);
      ArrayList<Movie> movies = canopyKmeansCenters.get(cId);
      if(movies == null)
        continue;
     
      for(Movie movie: movies) {
        if(hasCalcCenters.contains(movie))
          continue;
        hasCalcCenters.add(movie);
       
        double dst = movie.getComplexDistance(currentMovie);
        if(dst > maxDst) {
          maxDst = dst;
          maxMovie = movie;
        }
      }
     
    }
   
    if(maxDst > -1) {
      context.write(new Text(String.valueOf(maxMovie.getMovieId())),
          new Text(String.valueOf(movieId)+":"+data));
    }
   
  }
View Full Code Here

      String data = value.toString();
      int index = data.indexOf(":");
      int movieId = Integer.valueOf(data.substring(0, index));
      String datas = data.substring(index+1);
     
      Movie currentMovie = new Movie(movieId, datas);
      Map<Integer, Integer> features= currentMovie.getMap();
      for(Integer userId: features.keySet()) {
        if(!userRating.containsKey(userId)) {
          userRating.put(userId, 0);
          userCount.put(userId, 0);
        }
View Full Code Here

    SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
    Text key = new Text();
    Text value = new Text();
    try {
      while(reader.next(key, value)) {
        Movie movie = new Movie(Integer.valueOf(key.toString()), value.toString());
       
        this.canopyMovieCenters.add(movie);
      }
    }
    finally {
View Full Code Here

  public void map(Text key, Text value, Context context)
    throws IOException, InterruptedException {
   
    int movieId = Integer.valueOf(key.toString());
    String data = value.toString();
    Movie currentMovie = new Movie(movieId, data);
   
    boolean emit = false;
    StringBuilder sb = new StringBuilder();
    for(Movie canopyMovie: canopyMovieCenters) {
      if(currentMovie.getMatchCount(canopyMovie) >= ConfiguredKmeans.T2) {
        if(!emit) emit = true;
        if(sb.length() > 0)
          sb.append(":");
        sb.append(currentMovie.getMovieId());
      }
    }
   
    if(emit) {
      sb.append(":");
View Full Code Here

      InterruptedException {

    int movieId = Integer.valueOf(key.toString());
    String data = value.toString();

    Movie currentMovie = new Movie(movieId, data);

    boolean tooClose = false;
    for (Movie m : canopyMovieCenters) {
      if (m.getMatchCount(currentMovie) >= ConfiguredKmeans.T1) {
        tooClose = true;
View Full Code Here

    for (Text value : values) {
      String[] movieAndData = value.toString().split(":");
      int movieId = Integer.valueOf(movieAndData[0]);
      String data = movieAndData[1].toString();

      Movie currentMovie = new Movie(movieId, data);

      boolean tooClose = false;
      for (Movie m : canopyMovieCenters) {
        if (m.getMatchCount(currentMovie) >= ConfiguredKmeans.T1) {
          tooClose = true;
View Full Code Here

TOP

Related Classes of com.chine.kmeans.models.Movie

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.