/// <summary>
 /// Initializes a new instance of the <see cref="ColdUserItemParameterAlgorithm"/> class.
 /// </summary>
 /// <param name="userFeatureParameterPosteriors">The posteriors over the user feature related parameters learned during community training.</param>
 /// <param name="itemFeatureParameterPosteriors">The posteriors over the item feature related parameters learned during community training.</param>
 /// <param name="userParameterDistributionAverage">The average trait, bias, and threshold posterior over all users in training.</param>
 /// <param name="itemParameterDistributionAverage">The average trait and bias posterior over all items in training.</param>
 public ColdUserItemParameterAlgorithm(
     FeatureParameterDistribution userFeatureParameterPosteriors,
     FeatureParameterDistribution itemFeatureParameterPosteriors,
     UserParameterDistribution userParameterDistributionAverage,
     ItemParameterDistribution itemParameterDistributionAverage)
 {
     this.userFeatureParameterPosteriors   = userFeatureParameterPosteriors;
     this.itemFeatureParameterPosteriors   = itemFeatureParameterPosteriors;
     this.userParameterDistributionAverage = userParameterDistributionAverage;
     this.itemParameterDistributionAverage = itemParameterDistributionAverage;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the feature contribution for a given user/item to its traits and bias.
        /// </summary>
        /// <param name="parameters">The user/item parameters.</param>
        /// <param name="featureWeights">The feature weights.</param>
        /// <param name="featureValues">The feature values.</param>
        /// <param name="adjustedTraits">The resulting traits.</param>
        /// <param name="adjustedBias">The resulting bias.</param>
        public static void AddFeatureContribution(
            EntityParameterDistribution parameters,
            FeatureParameterDistribution featureWeights,
            SparseFeatureVector featureValues,
            out GaussianArray adjustedTraits,
            out Gaussian adjustedBias)
        {
            adjustedTraits = new GaussianArray(
                parameters.Traits.Count,
                i => DoublePlusOp.SumAverageConditional(
                    parameters.Traits[i],
                    ComputeFeatureContribution(featureWeights.TraitWeights[i], featureValues.NonZeroFeatureValues, featureValues.NonZeroFeatureIndices)));

            adjustedBias = DoublePlusOp.SumAverageConditional(
                parameters.Bias,
                ComputeFeatureContribution(featureWeights.BiasWeights, featureValues.NonZeroFeatureValues, featureValues.NonZeroFeatureIndices));
        }