ComputeCorrelations() 공개 메소드

Compute correlations for given ratings
public ComputeCorrelations ( IRatings ratings, EntityType entity_type ) : void
ratings IRatings the rating data
entity_type EntityType the entity type, either USER or ITEM
리턴 void
예제 #1
0
        /// <summary>Create a AdjustedCosine matrix from given data</summary>
        /// <param name="ratings">the ratings data</param>
        /// <param name="entity_type">the entity type, either USER or ITEM</param>
        /// <param name="shrinkage">a shrinkage parameter</param>
        /// <returns>the complete AdjustedCosine matrix</returns>
        static public CorrelationMatrix Create(IRatings ratings, EntityType entity_type, float shrinkage)
        {
            AdjustedCosine cm;
            int            num_entities = 0;

            if (entity_type.Equals(EntityType.USER))
            {
                num_entities = ratings.MaxUserID + 1;
            }
            else if (entity_type.Equals(EntityType.ITEM))
            {
                num_entities = ratings.MaxItemID + 1;
            }
            else
            {
                throw new ArgumentException("Unknown entity type: " + entity_type);
            }

            try
            {
                cm = new AdjustedCosine(num_entities);
            }
            catch (OverflowException)
            {
                Console.Error.WriteLine("Too many entities: " + num_entities);
                throw;
            }
            cm.shrinkage = shrinkage;
            cm.ComputeCorrelations(ratings, entity_type);
            return(cm);
        }
예제 #2
0
        /// <summary>Create a AdjustedCosine matrix from given data</summary>
        /// <param name="ratings">the ratings data</param>
        /// <param name="entity_type">the entity type, either USER or ITEM</param>
        /// <param name="shrinkage">a shrinkage parameter</param>
        /// <returns>the complete AdjustedCosine matrix</returns>
        public static CorrelationMatrix Create(IRatings ratings, EntityType entity_type, float shrinkage)
        {
            AdjustedCosine cm;
            int num_entities = 0;
            if (entity_type.Equals(EntityType.USER))
                num_entities = ratings.MaxUserID + 1;
            else if (entity_type.Equals(EntityType.ITEM))
                num_entities = ratings.MaxItemID + 1;
            else
                throw new ArgumentException("Unknown entity type: " + entity_type);

            try
            {
                cm = new AdjustedCosine(num_entities);
            }
            catch (OverflowException)
            {
                Console.Error.WriteLine("Too many entities: " + num_entities);
                throw;
            }
            cm.shrinkage = shrinkage;
            cm.ComputeCorrelations(ratings, entity_type);
            return cm;
        }