/// <summary>
 ///
 /// </summary>
 /// <param name="dataModel"><see cref="taste.Model.DataModel">DataModel</see> which provides <see cref="taste.mode.User">User</see>s</param>
 /// <param name="clusterSimilarity"><see cref="taste.Recommender.ClusterSimilarity">ClusterSimilarity</see> used to compute cluster similarity</param>
 /// <param name="numClusters">desired number of clusters to create</param>
 /// <param name="samplingPercentage">
 /// percentage of all cluster-cluster pairs to consider when finding
 /// next-most-similar clusters. Decreasing this value from 1.0 can increase performance at the
 /// cost of accuracy
 /// </param>
 public TreeClusteringRecommender(DataModel dataModel,
                                  ClusterSimilarity clusterSimilarity,
                                  int numClusters,
                                  double samplingPercentage)
     : base(dataModel)
 {
     if (clusterSimilarity == null)
     {
         throw new ArgumentNullException("clusterSimilarity is null");
     }
     if (numClusters < 2)
     {
         throw new ArgumentException("numClusters must be at least 2");
     }
     if (double.IsNaN(samplingPercentage) || samplingPercentage <= 0.0 || samplingPercentage > 1.0)
     {
         throw new ArgumentException("samplingPercentage is invalid: " + samplingPercentage);
     }
     this.clusterSimilarity     = clusterSimilarity;
     this.numClusters           = numClusters;
     this.clusteringThreshold   = Double.NaN;
     this.clusteringByThreshold = false;
     this.samplingPercentage    = samplingPercentage;
     this.refreshLock           = new ReentrantLock();
     this.buildClustersLock     = new ReentrantLock();
 }
 /// <summary>
 /// </summary>
 /// <param name="dataModel">
 /// <see cref="taste.Model.DataModel">DataModel</see> which provides <see cref="taste.Model.User">User</see>s
 /// </param>
 /// <param name="clusterSimilarity">
 /// <see cref="taste.Recommender.ClusterSimilarity">ClusterSimilarity</see> used to compute cluster similarity
 /// </param>
 /// <param name="clusteringThreshold">clustering similarity threshold; clusters will be aggregated
 /// into larger clusters until the next two nearest clusters' similarity drops below this threshold
 /// </param>
 /// <param name="samplingPercentage">
 /// percentage of all cluster-cluster pairs to consider when finding next-most-similar
 /// clusters. Decreasing this value from 1.0 can increase performance at the cost of accuracy
 /// </param>
 /// <remarks>
 /// Throws ArgumentException if arguments are <code>null</code>, or <code>clusteringThreshold</code> is
 /// {@link Double#NaN}, or samplingPercentage is {@link Double#NaN} or nonpositive or greater than 1.0
 /// </remarks>
 public TreeClusteringRecommender(DataModel dataModel,
                                  ClusterSimilarity clusterSimilarity,
                                  double clusteringThreshold,
                                  double samplingPercentage)
     : base(dataModel)
 {
     if (clusterSimilarity == null)
     {
         throw new ArgumentNullException("clusterSimilarity is null");
     }
     if (double.IsNaN(clusteringThreshold))
     {
         throw new ArgumentException("clusteringThreshold must not be NaN");
     }
     if (double.IsNaN(samplingPercentage) || samplingPercentage <= 0.0 || samplingPercentage > 1.0)
     {
         throw new ArgumentException("samplingPercentage is invalid: " + samplingPercentage);
     }
     this.clusterSimilarity     = clusterSimilarity;
     this.numClusters           = int.MinValue;
     this.clusteringThreshold   = clusteringThreshold;
     this.clusteringByThreshold = true;
     this.samplingPercentage    = samplingPercentage;
     this.refreshLock           = new ReentrantLock();
     this.buildClustersLock     = new ReentrantLock();
 }
        /**
         * @param dataModel
         *          {@link DataModel} which provides users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster similarity
         * @param numClusters
         *          desired number of clusters to create
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code numClusters} is less than 2
         */

        public TreeClusteringRecommender2(DataModel dataModel, ClusterSimilarity clusterSimilarity, int numClusters)
            : base(dataModel)
        {
            if (numClusters < 2)
            {
                throw new Exception("numClusters must be at least 2");
            }
            //Preconditions.checkArgument(numClusters >= 2, "numClusters must be at least 2");
            this.clusterSimilarity     = clusterSimilarity;//Preconditions.checkNotNull(clusterSimilarity);
            this.numClusters           = numClusters;
            this.clusteringThreshold   = Double.NaN;
            this.clusteringByThreshold = false;
            this.refreshHelper         = new RefreshHelper(buildClusters);
            refreshHelper.addDependency(dataModel);
            refreshHelper.addDependency(clusterSimilarity);
            buildClusters();
        }
        /**
         * @param dataModel
         *          {@link DataModel} which provides users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster
         *          similarity
         * @param clusteringThreshold
         *          clustering similarity threshold; clusters will be aggregated into larger clusters until the next
         *          two nearest clusters' similarity drops below this threshold
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code clusteringThreshold} is {@link Double#NaN}
         */

        public TreeClusteringRecommender2(DataModel dataModel,
                                          ClusterSimilarity clusterSimilarity,
                                          double clusteringThreshold)
            : base(dataModel)
        {
            //  Preconditions.checkArgument(!Double.isNaN(clusteringThreshold), "clusteringThreshold must not be NaN");
            if (Double.IsNaN(clusteringThreshold))
            {
                throw new Exception("clusteringThreshold must not be NaN");
            }
            this.clusterSimilarity     = clusterSimilarity; //Preconditions.checkNotNull(clusterSimilarity);
            this.numClusters           = int.MinValue;      // Integer.MIN_VALUE;
            this.clusteringThreshold   = clusteringThreshold;
            this.clusteringByThreshold = true;
            this.refreshHelper         = new RefreshHelper(buildClusters);
            refreshHelper.addDependency(dataModel);
            refreshHelper.addDependency(clusterSimilarity);
            buildClusters();
        }
        /**
         * @param dataModel
         *          {@link DataModel} which provides users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster similarity
         * @param clusteringThreshold
         *          clustering similarity threshold; clusters will be aggregated into larger clusters until the next
         *          two nearest clusters' similarity drops below this threshold
         * @param samplingRate
         *          percentage of all cluster-cluster pairs to consider when finding next-most-similar clusters.
         *          Decreasing this value from 1.0 can increase performance at the cost of accuracy
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code clusteringThreshold} is {@link Double#NaN},
         *           or samplingRate is {@link Double#NaN} or nonpositive or greater than 1.0
         */

        public TreeClusteringRecommender(DataModel dataModel,
                                         ClusterSimilarity clusterSimilarity,
                                         double clusteringThreshold,
                                         double samplingRate)
            : base(dataModel)
        {
            //Preconditions.checkArgument(!Double.IsNaN(clusteringThreshold), "clusteringThreshold must not be NaN");
            //Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "samplingRate is invalid: %f", samplingRate);
            random = RandomUtils.getRandom();
            this.clusterSimilarity     = clusterSimilarity; //Preconditions.checkNotNull(clusterSimilarity);
            this.numClusters           = int.MinValue;      //Integer.MIN_VALUE;
            this.clusteringThreshold   = clusteringThreshold;
            this.clusteringByThreshold = true;
            this.samplingRate          = samplingRate;
            this.refreshHelper         = new RefreshHelper(buildClusters);
            refreshHelper.addDependency(dataModel);
            refreshHelper.addDependency(clusterSimilarity);
            buildClusters();
        }
        /**
         * @param dataModel
         *          {@link DataModel} which provdes users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster similarity
         * @param numClusters
         *          desired number of clusters to create
         * @param samplingRate
         *          percentage of all cluster-cluster pairs to consider when finding next-most-similar clusters.
         *          Decreasing this value from 1.0 can increase performance at the cost of accuracy
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code numClusters} is less than 2, or samplingRate
         *           is {@link Double#NaN} or nonpositive or greater than 1.0
         */

        public TreeClusteringRecommender(DataModel dataModel,
                                         ClusterSimilarity clusterSimilarity,
                                         int numClusters,
                                         double samplingRate)
            : base(dataModel)
        {
            //Preconditions.checkArgument(numClusters >= 2, "numClusters must be at least 2");
            //Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0,
            //  "samplingRate is invalid: %f", samplingRate);
            random = RandomUtils.getRandom();
            this.clusterSimilarity     = clusterSimilarity;//Preconditions.checkNotNull(clusterSimilarity);
            this.numClusters           = numClusters;
            this.clusteringThreshold   = Double.NaN;
            this.clusteringByThreshold = false;
            this.samplingRate          = samplingRate;
            this.refreshHelper         = new RefreshHelper(buildClusters);
            refreshHelper.addDependency(dataModel);
            refreshHelper.addDependency(clusterSimilarity);
            buildClusters();
        }
Esempio n. 7
0
 /**
  * @param dataModel {@link taste.Model.DataModel} which provdes {@link taste.Model.User}s
  * @param clusterSimilarity {@link taste.Recommender.ClusterSimilarity} used to compute
  *  cluster similarity
  * @param numClusters desired number of clusters to create
  * @throws IllegalArgumentException if arguments are <code>null</code>, or <code>numClusters</code> is
  *  less than 2
  */
 public TreeClusteringRecommender2(DataModel dataModel,
                                   ClusterSimilarity clusterSimilarity,
                                   int numClusters)
     : base(dataModel)
 {
     if (clusterSimilarity == null)
     {
         throw new ArgumentNullException("clusterSimilarity is null");
     }
     if (numClusters < 2)
     {
         throw new ArgumentException("numClusters must be at least 2");
     }
     this.clusterSimilarity     = clusterSimilarity;
     this.numClusters           = numClusters;
     this.clusteringThreshold   = Double.NaN;
     this.clusteringByThreshold = false;
     this.refreshLock           = new ReentrantLock();
     this.buildClustersLock     = new ReentrantLock();
 }
Esempio n. 8
0
 /**
  * @param dataModel {@link taste.Model.DataModel} which provdes {@link taste.Model.User}s
  * @param clusterSimilarity {@link taste.Recommender.ClusterSimilarity} used to compute
  *  cluster similarity
  * @param clusteringThreshold clustering similarity threshold; clusters will be aggregated into larger
  *  clusters until the next two nearest clusters' similarity drops below this threshold
  * @throws IllegalArgumentException if arguments are <code>null</code>, or <code>clusteringThreshold</code> is
  *  {@link Double#NaN}
  * @since 1.1.1
  */
 public TreeClusteringRecommender2(DataModel dataModel,
                                   ClusterSimilarity clusterSimilarity,
                                   double clusteringThreshold)
     : base(dataModel)
 {
     if (clusterSimilarity == null)
     {
         throw new ArgumentNullException("clusterSimilarity is null");
     }
     if (double.IsNaN(clusteringThreshold))
     {
         throw new ArgumentException("clusteringThreshold must not be NaN");
     }
     this.clusterSimilarity     = clusterSimilarity;
     this.numClusters           = int.MinValue;
     this.clusteringThreshold   = clusteringThreshold;
     this.clusteringByThreshold = true;
     this.refreshLock           = new ReentrantLock();
     this.buildClustersLock     = new ReentrantLock();
 }
        /**
         * @param dataModel
         *          {@link DataModel} which provdes users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster similarity
         * @param clusteringThreshold
         *          clustering similarity threshold; clusters will be aggregated into larger clusters until the next
         *          two nearest clusters' similarity drops below this threshold
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code clusteringThreshold} is {@link Double#NaN}
         */

        public TreeClusteringRecommender(DataModel dataModel,
                                         ClusterSimilarity clusterSimilarity,
                                         double clusteringThreshold) :
            this(dataModel, clusterSimilarity, clusteringThreshold, 1.0)
        {
        }
        /**
         * @param dataModel
         *          {@link DataModel} which provdes users
         * @param clusterSimilarity
         *          {@link ClusterSimilarity} used to compute cluster similarity
         * @param numClusters
         *          desired number of clusters to create
         * @throws IllegalArgumentException
         *           if arguments are {@code null}, or {@code numClusters} is less than 2
         */

        public TreeClusteringRecommender(DataModel dataModel, ClusterSimilarity clusterSimilarity, int numClusters)
            : this(dataModel, clusterSimilarity, numClusters, 1.0)
        {
        }