예제 #1
0
 /**
  * @param threshold similarity threshold
  * @param userCorrelation similarity metric
  * @param dataModel data Model
  * @param samplingRate percentage of users to consider when building Neighborhood -- decrease to
  *  trade quality for performance
  * @throws IllegalArgumentException if threshold or samplingRate is {@link Double#NaN},
  *  or if samplingRate is not positive and less than or equal to 1.0, or if userCorrelation
  *  or dataModel are <code>null</code>
  * @since 1.3
  */
 public ThresholdUserNeighborhood(double threshold,
                                  UserCorrelation userCorrelation,
                                  DataModel dataModel,
                                  double samplingRate)
     : base(userCorrelation, dataModel, samplingRate)
 {
     if (Double.IsNaN(threshold))
     {
         throw new ArgumentException("threshold must not be NaN");
     }
     this.cache = new SoftCache <Object, ICollection <User> >(new Retriever(this, threshold), dataModel.GetNumUsers());
 }
예제 #2
0
 /// <summary>
 /// construct a NearestNUserNeighborhood
 /// </summary>
 /// <param name="n">n Neighborhood size</param>
 /// <param name="userCorrelation">nearness metric</param>
 /// <param name="dataModel">data Model</param>
 /// <param name="samplingRate">percentage of users to consider when building Neighborhood -- decrease to
 /// trade quality for performance</param>
 public NearestNUserNeighborhood(int n,
                                 UserCorrelation userCorrelation,
                                 DataModel dataModel,
                                 double samplingRate)
     : base(userCorrelation, dataModel, samplingRate)
 {
     if (n < 1)
     {
         throw new ArgumentException("n must be at least 1");
     }
     this.cache = new SoftCache <Object, ICollection <User> >(new Retriever(this, n), dataModel.GetNumUsers());
 }
예제 #3
0
        public CachingRecommender(Recommender recommender)
        {
            if (recommender == null)
            {
                throw new ArgumentNullException("Recommender is null");
            }
            this.recommender = recommender;
            this.maxHowMany  = new AtomicInteger(1);
            // Use "num users" as an upper limit on cache size. Rough guess.
            int numUsers = recommender.DataModel.GetNumUsers();

            this.recommendationCache =
                new SoftCache <Object, Recommendations>(
                    new RecommendationRetriever(this.recommender, this.maxHowMany),
                    numUsers);
            this.estimatedPrefCache =
                new SoftCache <Pair <object, object>, Double>(new EstimatedPrefRetriever(this.recommender), numUsers);
            this.refreshLock = new ReentrantLock();
        }
예제 #4
0
파일: ZScore.cs 프로젝트: radtek/taste.net
 public ZScore()
 {
     this.meanAndStdevs = new SoftCache <User, RunningAverageAndStdDev>(new MeanStdevRetriever());
     Refresh();
 }
 public AveragingPreferenceInferrer(DataModel dataModel)
 {
     averagePreferenceValue = new SoftCache <User, Double>(RETRIEVER, dataModel.GetNumUsers());
     Refresh();
 }