/// <summary>Computations that depend on the observed value of FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary> /// <param name="numberOfIterations">The number of times to iterate each loop</param> private void Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7(int numberOfIterations) { if (this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone) { return; } for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++) { for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { this.Weights_FeatureIndexes_F[InstanceRange] = JaggedSubarrayWithMarginalOp <double> .ItemsAverageConditional <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_uses_F[1], this.Weights_marginal_F, this.featureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[InstanceRange]); for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]); } 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 InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][InstanceFeatureRanges], this.featureValues[InstanceRange][InstanceFeatureRanges]); } this.Weights_marginal_F = JaggedSubarrayWithMarginalOp <double> .MarginalIncrementItems <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_FeatureIndexes_F[InstanceRange], this.featureIndexes, InstanceRange, this.Weights_marginal_F); } this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); } this.Weights_uses_B[1] = JaggedSubarrayWithMarginalOp <double> .ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[1], this.Weights_marginal_F, this.Weights_uses_B[1]); this.Weights_B = ReplicateOp_NoDivide.DefAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_B); this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone = true; }
/// <summary>Computations that depend on the observed value of numberOfIterationsDecreased and WeightPriors and FeatureIndexes and InstanceCount and InstanceFeatureCounts and FeatureValues and Labels and WeightConstraints</summary> /// <param name="numberOfIterations">The number of times to iterate each loop</param> private void Changed_numberOfIterationsDecreased_WeightPriors_FeatureIndexes_InstanceCount_InstanceFeatureCounts_7(int numberOfIterations) { if (this.Changed_numberOfIterationsDecreased_WeightPriors_FeatureIndexes_InstanceCount_InstanceFeatureCounts_7_iterationsDone == numberOfIterations) { return; } for (int iteration = this.Changed_numberOfIterationsDecreased_WeightPriors_FeatureIndexes_InstanceCount_InstanceFeatureCounts_7_iterationsDone; iteration < numberOfIterations; iteration++) { // Message to 'Weights_uses' from Replicate factor this.Weights_uses_B_toDef = ReplicateOp_Divide.ToDef <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_uses_B_toDef); // Message to 'Weights_uses' from Replicate factor this.Weights_uses_F_marginal = ReplicateOp_Divide.Marginal <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B_toDef, this.weightPriors, this.Weights_uses_F_marginal); // Message to 'Weights_uses' from Replicate factor this.Weights_uses_F[1] = ReplicateOp_Divide.UsesAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B[1], this.Weights_uses_F_marginal, 1, this.Weights_uses_F[1]); // Message to 'Weights_FeatureIndexes' from JaggedSubarray factor this.Weights_uses_F_1__marginal = JaggedSubarrayOp <double> .Marginal <DistributionStructArray <Gaussian, double>, Gaussian, object, DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_uses_F_1__marginal); for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { // Message to 'Weights_FeatureIndexes' from JaggedSubarray factor this.Weights_FeatureIndexes_F[InstanceRange] = JaggedSubarrayOp <double> .ItemsAverageConditional <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_uses_F[1], this.Weights_uses_F_1__marginal, this.featureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[InstanceRange]); for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { // Message to 'FeatureScores' from Product factor this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = GaussianProductOp.ProductAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]); } // Message to 'Score' from Sum factor this.Score_F[InstanceRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]); // Message to 'NoisyScore' from GaussianFromMeanAndVariance factor this.NoisyScore_F[InstanceRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0); // Message to 'NoisyScore_use' from IsPositive factor this.NoisyScore_use_B[InstanceRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(this.labels[InstanceRange]), this.NoisyScore_F[InstanceRange]); // Message to 'Score' from GaussianFromMeanAndVariance factor this.Score_B[InstanceRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScore_use_B[InstanceRange], 1.0); // Message to 'FeatureScores' from Sum factor 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 InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { // Message to 'IndexedWeights' from Product factor this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = GaussianProductOp.BAverageConditional(this.FeatureScores_B[InstanceRange][InstanceFeatureRanges], this.featureValues[InstanceRange][InstanceFeatureRanges]); } this.Weights_uses_F_1__marginal = JaggedSubarrayOp <double> .MarginalIncrement <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.Weights_uses_F_1__marginal, this.Weights_FeatureIndexes_F[InstanceRange], this.IndexedWeights_B[InstanceRange], this.featureIndexes, InstanceRange); } // Message to 'Weights_uses' from JaggedSubarray factor this.Weights_uses_B[1] = JaggedSubarrayOp <double> .ArrayAverageConditional <Gaussian, DistributionStructArray <Gaussian, double>, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B, this.featureIndexes, this.Weights_uses_B[1]); this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); } // Message to 'Weights_uses' from Replicate factor this.Weights_uses_B_toDef = ReplicateOp_Divide.ToDef <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_uses_B_toDef); // Message to 'Weights_marginal' from Variable factor this.Weights_marginal_F = VariableOp.MarginalAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B_toDef, this.weightPriors, this.Weights_marginal_F); this.Changed_numberOfIterationsDecreased_WeightPriors_FeatureIndexes_InstanceCount_InstanceFeatureCounts_7_iterationsDone = numberOfIterations; }
/// <summary>Computations that depend on the observed value of FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary> /// <param name="numberOfIterations">The number of times to iterate each loop</param> private void Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7(int numberOfIterations) { if (this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone) { return; } for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++) { for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { this.Weights_FeatureIndexes_F[InstanceRange] = JaggedSubarrayWithMarginalOp <double> .ItemsAverageConditional <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_uses_F[1], this.Weights_marginal_F, this.featureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[InstanceRange]); for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]); } 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 InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][InstanceFeatureRanges], this.featureValues[InstanceRange][InstanceFeatureRanges]); } this.Weights_marginal_F = JaggedSubarrayWithMarginalOp <double> .MarginalIncrementItems <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_FeatureIndexes_F[InstanceRange], this.featureIndexes, InstanceRange, this.Weights_marginal_F); } this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); } for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { this.Weights_FeatureIndexes_B[InstanceRange] = ArrayHelper.SetTo <DistributionStructArray <Gaussian, double> >(this.Weights_FeatureIndexes_B[InstanceRange], this.IndexedWeights_B[InstanceRange]); } this.Weights_uses_B[1] = JaggedSubarrayWithMarginalOp <double> .ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[1], this.Weights_marginal_F, this.Weights_uses_B[1]); this.Weights_uses_F[0] = ReplicateOp_NoDivide.UsesAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, 0, this.Weights_uses_F[0]); this.ModelSelector_selector_cases_0_uses_B[3] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, this.Weights_uses_F)); this.ModelSelector_selector_cases_0_uses_B[4] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp <double[]> .LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[0], this.weightConstraints)); this.ModelSelector_selector_cases_0_uses_B[8] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp <double> .LogEvidenceRatio <Gaussian, DistributionRefArray <DistributionStructArray <Gaussian, double>, double[]>, DistributionStructArray <Gaussian, double> >(this.Weights_FeatureIndexes_B, this.Weights_uses_F[1], this.featureIndexes, this.Weights_FeatureIndexes_F)); for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { this.ModelSelector_selector_cases_0_rep9_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange])); } this.ModelSelector_selector_cases_0_uses_B[16] = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_rep9_B, this.ModelSelector_selector_cases_0_uses_B[16]); this.ModelSelector_selector_cases_0_B = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_uses_B, this.ModelSelector_selector_cases_0_B); this.ModelSelector_selector_cases_B[0] = ArrayHelper.SetTo <Bernoulli>(this.ModelSelector_selector_cases_B[0], this.ModelSelector_selector_cases_0_B); this.ModelSelector_selector_B = CasesOp.BAverageConditional(this.ModelSelector_selector_cases_B); this.ModelSelector_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(this.ModelSelector_selector_B, this.vBernoulli1, this.ModelSelector_marginal_F); this.Weights_B = ReplicateOp_NoDivide.DefAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_B); this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone = true; }
/// <summary>Computations that depend on the observed value of xValueCount and xValues and wPrior and xIndices</summary> public void Changed_xValueCount_xValues_wPrior_xIndices() { if (this.Changed_xValueCount_xValues_wPrior_xIndices_iterationsDone == 1) { return; } for (int userFeature = 0; userFeature < this.XValueCount; userFeature++) { this.product_F[userFeature] = GaussianProductOp.ProductAverageConditional(this.XValues[userFeature], this.wSparse_F[userFeature]); } this.score_F = FastSumOp.SumAverageConditional(this.product_F); this.Changed_xValueCount_xValues_wPrior_xIndices_iterationsDone = 1; this.Changed_biasPrior_xValueCount_xValues_wPrior_xIndices_iterationsDone = 0; this.Changed_y_biasPrior_xValueCount_xValues_wPrior_xIndices_iterationsDone = 0; }
/// <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 FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++) { this.Weights_depth1_B[FeatureRange] = ArrayHelper.SetTo <Gaussian>(this.Weights_depth1_B[FeatureRange], this.Weights_depth1_rep_B_toDef[FeatureRange]); } 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_B[_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; }
/// <summary> /// Computes the inner product of the feature weights and values. /// </summary> /// <param name="weights">The feature weights.</param> /// <param name="nonZeroValues">The sparse feature values.</param> /// <param name="nonZeroIndices">The sparse feature indices.</param> /// <returns>The contribution of the features.</returns> private static Gaussian ComputeFeatureContribution(IList <Gaussian> weights, IList <double> nonZeroValues, IList <int> nonZeroIndices) { Debug.Assert(nonZeroValues.Count == nonZeroIndices.Count, "The number of values must be equal to the number of indices."); int count = nonZeroValues.Count; var nonZeroWeights = new Gaussian[count]; SubarrayOp <double> .ItemsAverageConditional(weights, nonZeroIndices, nonZeroWeights); var products = new List <Gaussian>(count); for (int i = 0; i < count; ++i) { products.Add(GaussianProductOp.ProductAverageConditional(nonZeroWeights[i], nonZeroValues[i])); } return(FastSumOp.SumAverageConditional(products)); }
/// <summary>Computations that depend on the observed value of FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and WeightConstraints and WeightPriors</summary> private void Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPri6() { if (this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPri6_isDone) { return; } for (int InstanceRange = 0; InstanceRange < this.InstanceCount; InstanceRange++) { for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) { this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]); } this.Score_F[InstanceRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]); this.NoisyScore_F[InstanceRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0); this.Labels_F[InstanceRange] = IsPositiveOp.IsPositiveAverageConditional(this.NoisyScore_F[InstanceRange]); this.Labels_marginal_F[InstanceRange] = DerivedVariableOp.MarginalAverageConditional <Bernoulli>(this.Labels_use_B_reduced, this.Labels_F[InstanceRange], this.Labels_marginal_F[InstanceRange]); } this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPri6_isDone = true; }
/// <summary>Computations that depend on the observed value of InstanceCount and FeatureCount and FeatureValues and numberOfIterationsDecreased and WeightPriors and WeightConstraints</summary> private void Changed_InstanceCount_FeatureCount_FeatureValues_numberOfIterationsDecreased_WeightPriors_WeightCons10() { if (this.Changed_InstanceCount_FeatureCount_FeatureValues_numberOfIterationsDecreased_WeightPriors_WeightCons10_iterationsDone == 1) { return; } for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++) { for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++) { // Message to 'FeatureScores' from Product factor this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOp.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange]); } // Message to 'Score' from Sum factor this.Score_F[InstanceRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]); // Message to 'NoisyScore' from GaussianFromMeanAndVariance factor this.NoisyScore_F[InstanceRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0); // Message to 'Labels' from IsPositive factor this.Labels_F[InstanceRange] = IsPositiveOp.IsPositiveAverageConditional(this.NoisyScore_F[InstanceRange]); // Message to 'Labels_marginal' from DerivedVariable factor this.Labels_marginal_F[InstanceRange] = DerivedVariableOp.MarginalAverageConditional <Bernoulli>(this.Labels_use_B[InstanceRange], this.Labels_F[InstanceRange], this.Labels_marginal_F[InstanceRange]); } this.Changed_InstanceCount_FeatureCount_FeatureValues_numberOfIterationsDecreased_WeightPriors_WeightCons10_iterationsDone = 1; }