/// <summary>Computations that depend on the observed value of FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
 /// <param name="numberOfIterations">The number of times to iterate each loop</param>
 private void Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8(int numberOfIterations)
 {
     if (this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8_isDone)
     {
         return;
     }
     for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++)
     {
         for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
         {
             this.Weights_depth1_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal <Gaussian>(this.Weights_depth1_rep_B_toDef[FeatureRange], this.Weights_uses_F[1][FeatureRange], this.Weights_depth1_rep_F_marginal[FeatureRange]);
         }
         for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++)
         {
             for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
             {
                 this.Weights_depth1_rep_F[FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional <Gaussian>(this.Weights_depth1_rep_B[FeatureRange][InstanceRange], this.Weights_depth1_rep_F_marginal[FeatureRange], InstanceRange, this.Weights_depth1_rep_F[FeatureRange][InstanceRange]);
                 this.FeatureScores_F[InstanceRange][FeatureRange]      = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange]);
             }
             this.Score_F[InstanceRange]          = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]);
             this.NoisyScore_F[InstanceRange]     = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0);
             this.NoisyScore_use_B[InstanceRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(this.labels[InstanceRange]), this.NoisyScore_F[InstanceRange]);
             this.Score_B[InstanceRange]          = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScore_use_B[InstanceRange], 1.0);
             this.FeatureScores_B[InstanceRange]  = FastSumOp.ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Score_B[InstanceRange], this.Score_F[InstanceRange], this.FeatureScores_F[InstanceRange], this.FeatureScores_B[InstanceRange]);
             for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
             {
                 this.Weights_depth1_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
                 this.Weights_depth1_rep_F_marginal[FeatureRange]       = ReplicateOp_Divide.MarginalIncrement <Gaussian>(this.Weights_depth1_rep_F_marginal[FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange], this.Weights_depth1_rep_B[FeatureRange][InstanceRange]);
             }
         }
         for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
         {
             this.Weights_depth1_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef <Gaussian>(this.Weights_depth1_rep_B[FeatureRange], this.Weights_depth1_rep_B_toDef[FeatureRange]);
         }
         this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
     }
     for (int _iv = 0; _iv < this.featureCount; _iv++)
     {
         this.Weights_uses_B[1][_iv] = ArrayHelper.SetTo <Gaussian>(this.Weights_uses_B[1][_iv], this.Weights_depth1_rep_B_toDef[_iv]);
     }
     this.Weights_use_B      = ReplicateOp_NoDivide.DefAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_use_B);
     this.Weights_marginal_F = VariableOp.MarginalAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_use_B, this.weightPriors, this.Weights_marginal_F);
     this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8_isDone = true;
 }
Exemple #2
0
 /// <summary>Computations that depend on the observed value of y and biasPrior and xValueCount and xValues and wPrior and xIndices</summary>
 public void Changed_y_biasPrior_xValueCount_xValues_wPrior_xIndices()
 {
     if (this.Changed_y_biasPrior_xValueCount_xValues_wPrior_xIndices_iterationsDone == 1)
     {
         return;
     }
     this.vdouble13_use_B = IsPositiveOp.XAverageConditional(this.Y, this.vdouble13_F);
     this.vdouble11_B     = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.vdouble13_use_B, 1);
     this.bias_use_B      = DoublePlusOp.BAverageConditional(this.vdouble11_B, this.score_F);
     this.bias_marginal_F = VariableOp.MarginalAverageConditional <Gaussian>(this.bias_use_B, this.BiasPrior, this.bias_marginal_F);
     this.score_B         = DoublePlusOp.AAverageConditional(this.vdouble11_B, this.BiasPrior);
     this.product_B       = FastSumOp.ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.score_B, this.score_F, this.product_F, this.product_B);
     for (int userFeature = 0; userFeature < this.XValueCount; userFeature++)
     {
         this.wSparse_use_B[userFeature] = GaussianProductOp.BAverageConditional(this.product_B[userFeature], this.XValues[userFeature]);
     }
     this.wSparse_marginal_F = DerivedVariableOp.MarginalAverageConditional <DistributionStructArray <Gaussian, double> >(this.wSparse_use_B, this.wSparse_F,
                                                                                                                          this.wSparse_marginal_F);
     this.Changed_y_biasPrior_xValueCount_xValues_wPrior_xIndices_iterationsDone = 1;
 }