WetGlassSprinklerRainModel has flexible state counts (#402)

* Expanded CausalityExample
* Variable.Dirichlet and Discrete check the array size
* IterativeProcessTransform ensures Marginal methods have unique names
* DependencyGraph.initializedEdges overrides required edges
* DependencyAnalysisTransform requires gated definitions to fully precede their uses
This commit is contained in:
Tom Minka 2022-04-08 20:14:57 +01:00 коммит произвёл GitHub
Родитель f008e6c719
Коммит ca25068ead
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
41 изменённых файлов: 6444 добавлений и 6007 удалений

Просмотреть файл

@ -13,7 +13,6 @@ using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Utilities;
using NodeIndex = System.Int32;
using EdgeIndex = System.Int32;
using Microsoft.ML.Probabilistic.Compiler;
namespace Microsoft.ML.Probabilistic.Compiler.Graphs
{
@ -411,6 +410,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Graphs
source = target;
}
Debug.WriteLine("");
// To debug this exception, set SchedulingTransform.debug = true
// and check if any edge on this cycle was forced forward.
throw new InferCompilerException("Cycle of forward edges");
};
dfsScheduleWithGroups.FinishNode += node => groupSchedule.Add(node);

Просмотреть файл

@ -156,10 +156,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Attributes
public void PreventLoopMerging(IStatement mutated, IStatement affected, ICollection<IVariableDeclaration> loopVars)
{
int edge;
int source = indexOf[mutated];
int target = indexOf[affected];
if (!graph.TryGetEdge(source, target, out edge))
if (!graph.TryGetEdge(source, target, out int edge))
{
edge = graph.AddEdge(source, target);
prohibitedLoopVars[edge] = loopVars;
@ -178,19 +177,14 @@ namespace Microsoft.ML.Probabilistic.Compiler.Attributes
public void SetOffsetInfo(IStatement mutated, IStatement affected, IOffsetInfo offsetInfo)
{
int edge;
int source = indexOf[mutated];
int target = indexOf[affected];
if (!graph.TryGetEdge(source, target, out edge))
if (!graph.TryGetEdge(source, target, out int edge))
{
edge = graph.AddEdge(source, target);
prohibitedLoopVars[edge] = null;
offsetInfos[edge] = offsetInfo;
}
else
{
offsetInfos[edge] = offsetInfo;
}
offsetInfos[edge] = offsetInfo;
}
public IStatement GetStatement(int index)

Просмотреть файл

@ -2450,7 +2450,7 @@ namespace Microsoft.ML.Probabilistic.Models
if (probs.Length == 0) return DiscreteUniform(valueRange);
else
{
if (valueRange.SizeAsInt != probs.Length) throw new ArgumentException("probs.Length (" + probs.Length + ") != range.Size (" + valueRange.SizeAsInt + ")");
if (valueRange.SizeAsInt != probs.Length) throw new ArgumentException($"probs.Length ({probs.Length}) != range.Size ({valueRange.SizeAsInt})");
return Variable<int>.Random(Constant(new Discrete(probs)))
.Attrib(new ValueRange(valueRange));
}
@ -2481,6 +2481,7 @@ namespace Microsoft.ML.Probabilistic.Models
/// <returns>Returns a random variable that is statistically defined by the specified Discrete distribution.</returns>
public static Variable<int> Discrete(Range valueRange, Vector v)
{
if (valueRange.SizeAsInt != v.Count) throw new ArgumentException($"Vector length ({v.Count}) != range.Size ({valueRange.SizeAsInt})");
var rv = Discrete(v.ToArray()).Attrib(new ValueRange(valueRange));
if (!v.Sparsity.IsDense)
rv.SetSparsity(v.Sparsity);
@ -2870,12 +2871,16 @@ namespace Microsoft.ML.Probabilistic.Models
/// Creates a Dirichlet-distributed random variable with the dimensionality specified by
/// a <c>Range</c> object and a specified set of pseudo-counts.
/// </summary>
/// <param name="valueRange">A <c>Range</c> object that is initialized to the Dirichlet
/// <param name="valueRange">A <c>Range</c> object that is initialized to the Dirichlet
/// distribution's dimensionality.</param>
/// <param name="u">An array containing the pseudo-counts.</param>
/// <returns>Returns a Dirichlet-distributed random variable of dimension <paramref name="u"/></returns>
public static Variable<Vector> Dirichlet(Range valueRange, double[] u)
{
if (valueRange.SizeAsInt != u.Length)
{
throw new ArgumentException($"The range size ({valueRange.SizeAsInt}) does not match the array length ({u.Length})");
}
return Dirichlet(u).Attrib(new ValueRange(valueRange));
}
@ -2922,6 +2927,10 @@ namespace Microsoft.ML.Probabilistic.Models
/// by <paramref name="v"/>.</returns>
public static Variable<Vector> Dirichlet(Range valueRange, Vector v)
{
if (valueRange.SizeAsInt != v.Count)
{
throw new ArgumentException($"The range size ({valueRange.SizeAsInt}) does not match the vector length ({v.Count})");
}
return Dirichlet(v).Attrib(new ValueRange(valueRange));
}

Просмотреть файл

@ -26,18 +26,16 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
lhs = condition;
rhs = Builder.LiteralExpr(true);
if (condition is IBinaryExpression)
if (condition is IBinaryExpression ibe)
{
IBinaryExpression ibe = (IBinaryExpression) condition;
if ((ibe.Operator == BinaryOperator.IdentityEquality) || (ibe.Operator == BinaryOperator.ValueEquality))
{
lhs = ibe.Left;
rhs = ibe.Right;
}
}
else if (condition is IUnaryExpression)
else if (condition is IUnaryExpression iue)
{
IUnaryExpression iue = (IUnaryExpression) condition;
if (iue.Operator == UnaryOperator.BooleanNot)
{
lhs = iue.Expression;
@ -48,9 +46,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
public IExpression GetExpression()
{
if (rhs is ILiteralExpression && rhs.GetExpressionType().Equals(typeof (bool)))
if (rhs is ILiteralExpression ile && ile.GetExpressionType().Equals(typeof (bool)))
{
bool value = (bool) ((ILiteralExpression) rhs).Value;
bool value = (bool) ile.Value;
if (value) return lhs;
else return Builder.UnaryExpr(UnaryOperator.BooleanNot, lhs);
}
@ -62,9 +60,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
public ConditionBinding FlipCondition()
{
if (rhs.GetExpressionType().Equals(typeof (bool)) && (rhs is ILiteralExpression))
if (rhs is ILiteralExpression ile && ile.GetExpressionType().Equals(typeof (bool)))
{
IExpression rhs2 = Builder.LiteralExpr(!(bool) ((ILiteralExpression) rhs).Value);
IExpression rhs2 = Builder.LiteralExpr(!(bool) ile.Value);
return new ConditionBinding(lhs, rhs2);
}
else
@ -93,10 +91,10 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
public override string ToString()
{
if (rhs is ILiteralExpression && rhs.GetExpressionType().Equals(typeof (bool)))
if (rhs is ILiteralExpression ile && ile.GetExpressionType().Equals(typeof (bool)))
{
string lhsString = lhs.ToString();
bool value = (bool) ((ILiteralExpression) rhs).Value;
bool value = (bool) ile.Value;
if (value)
return lhsString;
else

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -307,8 +307,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IStatement source = nodes[sourceIndex];
if (context.InputAttributes.Has<InitialiseBackward>(source) && targetIsIncrement)
initializedEdges.Add(edge);
IOffsetInfo offsetIndices;
if (di.offsetIndexOf.TryGetValue(source, out offsetIndices))
if (di.offsetIndexOf.TryGetValue(source, out IOffsetInfo offsetIndices))
{
OffsetIndices[edge] = offsetIndices;
}
@ -316,8 +315,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
deps.Clear();
foreach (IStatement source in di.DeclDependencies)
{
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
if (!sources.Contains(sourceIndex))
{
@ -367,8 +365,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
bool targetIsInitializer = context.InputAttributes.Has<Initializer>(ist);
foreach (IStatement source in di.Overwrites)
{
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
// write-after-write dependency
newEdges.Add(new Edge<NodeIndex>(sourceIndex, targetIndex));
@ -435,8 +432,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// label 'trigger' edges
foreach (IStatement source in di.Triggers.Where(dep => ignoreRequirements || !di.HasDependency(DependencyType.NoInit, dep)))
{
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
try
{
@ -467,8 +463,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// this is necessary until RepairSchedule is aware of offsets
if (di.offsetIndexOf.ContainsKey(source))
continue;
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
try
{
@ -489,8 +484,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// label 'noInit' edges
foreach (IStatement source in di.GetDependenciesOfType(DependencyType.NoInit))
{
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
try
{
@ -669,9 +663,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
bool topLevel = (anyCounter == 0);
foreach (IStatement source in sources)
{
if (source is AnyStatement)
if (source is AnyStatement anyBlock)
{
AnyStatement anyBlock = (AnyStatement)source;
List<IStatement> children = new List<IStatement>();
children.AddRange(anyBlock.Statements);
if (children.Count == 1)
@ -691,14 +684,15 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
else
{
int sourceIndex;
if (indexOfNode.TryGetValue(source, out sourceIndex))
if (indexOfNode.TryGetValue(source, out int sourceIndex))
{
try
{
int edge = dependencyGraph.GetEdge(sourceIndex, targetIndex);
if (topLevel)
{
isRequired[edge] = true;
}
else
{
// inside an AnyStatement

Просмотреть файл

@ -30,12 +30,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
}
List<IStatement> containers = new List<IStatement>();
List<IStatement> cloneDecls = new List<IStatement>();
List<IStatement> cloneUpdates = new List<IStatement>();
readonly List<IStatement> containers = new List<IStatement>();
readonly List<IStatement> cloneDecls = new List<IStatement>();
readonly List<IStatement> cloneUpdates = new List<IStatement>();
private LoopMergingInfo loopMergingInfo;
internal static bool debug = false;
private ModelCompiler compiler;
private readonly ModelCompiler compiler;
internal InitializerTransform(ModelCompiler compiler)
{

Просмотреть файл

@ -7,17 +7,16 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Compiler.Attributes;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Compiler.Graphs;
using Microsoft.ML.Probabilistic.Distributions;
using Microsoft.ML.Probabilistic.Utilities;
using Microsoft.ML.Probabilistic.Factors.Attributes;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Models.Attributes;
using Microsoft.ML.Probabilistic.Utilities;
using NodeIndex = System.Int32;
using EdgeIndex = System.Int32;
using Microsoft.ML.Probabilistic.Models.Attributes;
namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
@ -60,6 +59,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
private readonly Set<string> reallocatedVariables = new Set<string>();
private readonly Dictionary<object, IFieldDeclaration> fieldDeclarations = new Dictionary<object, IFieldDeclaration>();
private readonly Dictionary<object, IExpression> propertyReferences = new Dictionary<object, IExpression>();
private readonly Dictionary<IParameterDeclaration, IList<IStatement>> propertySetterStatements = new Dictionary<IParameterDeclaration, IList<IStatement>>();
private IList<IStatement> marginalMethodStmts, marginalQueryMethodStmts;
private IList<IStatement> marginalTMethodStmts, marginalQueryTMethodStmts;
@ -188,12 +188,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return ipd;
VariableInformation vi = VariableInformation.GetVariableInformation(context, ipd);
ITypeDeclaration td = context.FindOutputForAncestor<ITypeDeclaration, ITypeDeclaration>();
IFieldDeclaration fd = Builder.FieldDecl(FactorManager.FlipCapitalization(ipd.Name), ipd.ParameterType.DotNetType, td);
IFieldDeclaration fd = Builder.FieldDecl(ipd.Name + "_field", ipd.ParameterType.DotNetType, td);
fd.Documentation = "Field backing the " + ipd.Name + " property";
context.OutputAttributes.Set(fd, vi);
context.AddMember(fd);
td.Fields.Add(fd);
fieldDeclarations[ipd] = fd;
IFieldReferenceExpression fre = Builder.FieldRefExpr(fd);
IPropertyDeclaration prop = Builder.PropDecl(ipd.Name, ipd.ParameterType.DotNetType, td, MethodVisibility.Public, MethodVisibility.Public, out IExpression value);
prop.Documentation = "The externally-specified value of '" + ipd.Name + "'";
@ -286,6 +285,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// add lines to SetObservedValue()
IExpression pre = Builder.PropRefExpr(Builder.ThisRefExpr(), prop);
propertyReferences[ipd] = pre;
IConditionStatement cs2 = Builder.CondStmt(Builder.BinaryExpr(setObservedVariableName, BinaryOperator.ValueEquality, Builder.LiteralExpr(ipd.Name)),
Builder.BlockStmt());
cs2.Then.Statements.Add(Builder.AssignStmt(pre, Builder.CastExpr(setObservedValue, ipd.ParameterType)));
@ -1563,6 +1563,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IParameterDeclaration ipd = iare.Parameter.Resolve();
if (fieldDeclarations.TryGetValue(ipd, out IFieldDeclaration ifd))
return Builder.FieldRefExpr(ifd);
else if (propertyReferences.TryGetValue(ipd, out IExpression expr))
return expr;
else
return iare;
}
@ -1664,7 +1666,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
if (query == null)
{
CreateOutputMethod(varName, "Marginal", targetExpr);
CreateOutputMethod("Marginal", targetExpr);
}
else
{
@ -1674,9 +1676,15 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
CreateOutputMethodWithPath(varName, query.Name, path, targetExpr, query == QueryTypes.Marginal);
}
else
CreateOutputMethod(varName, query.Name, targetExpr);
CreateOutputMethod(query.Name, targetExpr);
}
return null;
void CreateOutputMethod(string suffix, IExpression expr)
{
bool isMarginal = (suffix != QueryTypes.MarginalDividedByPrior.Name);
CreateOutputMethodWithPath(varName, suffix, null, expr, isMarginal);
}
}
/// <summary>
@ -1739,23 +1747,6 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
);
}
protected void CreateOutputMethod(string varName, string suffix, IExpression expr)
{
bool isMarginal = (suffix != QueryTypes.MarginalDividedByPrior.Name);
CreateOutputMethodWithPath(varName, suffix, null, expr, isMarginal);
}
private bool HasMethod(ITypeDeclaration td, string name)
{
foreach (IMethodDeclaration imd in td.Methods)
{
if (imd.Name == name)
return true;
}
return false;
}
protected void AddMarginalMethod(string varName, IMethodDeclaration md)
{
IExpression variableName = marginalVariableName;
@ -1807,9 +1798,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
// Create marginal method and add return statement.
string name = CodeBuilder.MakeValid(CodeBuilder.Capitalise(varName + query));
if (HasMethod(td, name))
return;
string name = GetUniqueMethodName(td, CodeBuilder.Capitalise(varName + query));
IMethodDeclaration md = Builder.MethodDecl(MethodVisibility.Public, name, type, td);
string queryDoc = query.ToString();
if (queryDoc == QueryTypes.Marginal.Name) queryDoc = "marginal distribution";
@ -1894,7 +1883,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
basename = CodeBuilder.MakeValid(basename);
string s = basename;
int i = 1;
while (IsFieldOfName(td, s))
while (HasField(td, s))
{
s = basename + "_" + i;
i++;
@ -1902,13 +1891,39 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return s;
}
protected bool IsFieldOfName(ITypeDeclaration td, string name)
protected bool HasField(ITypeDeclaration td, string name)
{
foreach (IFieldDeclaration fd in td.Fields)
if (fd.Name.Equals(name))
return true;
return false;
}
protected string GetUniqueMethodName(ITypeDeclaration td, string basename)
{
int k = basename.IndexOf('`');
if (k != -1)
basename = basename.Substring(0, k);
basename = CodeBuilder.MakeValid(basename);
string s = basename;
int i = 1;
while (HasMethod(td, s))
{
s = basename + "_" + i;
i++;
}
return s;
}
private bool HasMethod(ITypeDeclaration td, string name)
{
foreach (IMethodDeclaration imd in td.Methods)
{
if (imd.Name == name)
return true;
}
return false;
}
}
/// <summary>

Просмотреть файл

@ -167,7 +167,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
foreach (EdgeIndex edge in forcedBackEdges)
{
if (direction[edge] == Direction.Forward)
{
throw new Exception($"Internal: {EdgeToString(edge)} was not forced backward");
}
// no need to Debug.WriteLine the edge here since it was already printed when added to forcedBackEdges.
direction[edge] = Direction.Backward;
newBackEdges.Push(edge);
@ -401,11 +403,14 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
continue;
foreach (EdgeIndex edgeOrig in dg.dependencyGraph.EdgesOutOf(node))
{
NodeIndex targetOrig = dg.dependencyGraph.TargetOf(edgeOrig);
if (targetOrig == node) continue;
if (dg.initializedEdges.Contains(edgeOrig)) continue;
if (dg.isRequired[edgeOrig])
{
foreach (NodeIndex source in newNodes[node])
{
foreach (NodeIndex target in newNodes[dg.dependencyGraph.TargetOf(edgeOrig)])
foreach (NodeIndex target in newNodes[targetOrig])
{
EdgeIndex edge;
if (!g.TryGetEdge(source, target, out edge))
@ -424,11 +429,15 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
foreach (NodeIndex source in newNodes[node])
{
foreach (NodeIndex target in newNodes[dg.dependencyGraph.TargetOf(edgeOrig)])
foreach (NodeIndex target in newNodes[targetOrig])
{
EdgeIndex edge;
if (!g.TryGetEdge(source, target, out edge))
continue;
if (verbose)
{
Debug.WriteLine($"mustNotInit incremented edgeCost[{EdgeToString(edge)}] by 10 because {source} must not init");
}
edgeCost[edge] += 10f;
}
}
@ -464,7 +473,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
if (float.IsPositiveInfinity(edgeCostInit[edge]) && (direction[edge] == Direction.Unknown))
{
if (debug)
Debug.WriteLine($"mustNotInit forced edge {EdgeToString(edge)} Forward");
Debug.WriteLine($"mustNotInit forced edge {EdgeToString(edge)} Forward due to Any dependency");
direction[edge] = Direction.Forward;
forcedForwardEdges.Add(edge);
todo.Push(edge);
@ -775,6 +784,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
//if (!notInitialized && !initsCanBeStale)
if (!notInitialized)
continue;
if (dg.initializedEdges.Contains(originalEdge[edge]))
continue;
if (IsOffsetEdge(originalEdge[edge]))
continue;
if (dg.mustNotInit != null && dg.mustNotInit.Contains(originalNode[source]))
@ -1933,6 +1944,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
NodeIndex target = g.TargetOf(edge);
NodeIndex originalTarget = originalNode[target];
EdgeIndex edgeOrig = originalEdge[edge];
// TODO: exclude initializedEdges
if (dg.isRequired[edgeOrig])
requiredCount++;
}
@ -2220,7 +2232,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
EdgeIndex edgeOrig = originalEdge[edge];
if (edgeOrig == -1)
return 0.1f * scale;
if (dg.initializedNodes.Contains(source))
if (dg.initializedNodes.Contains(source) || dg.initializedEdges.Contains(edgeOrig))
return 0.001f;
if (!dg.hasNonUniformInitializer.Contains(source))
{
@ -3154,6 +3166,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return satisfiable;
}
// Called when edge has infinite reversal cost and yet was chosen to be reversed
private void ShowConflict(EdgeIndex edge)
{
Debug.WriteLine("conflict at " + EdgeToString(edge));

Просмотреть файл

@ -258,12 +258,15 @@ namespace Microsoft.ML.Probabilistic.Compiler
// helper for MutatingFirstAffectsSecond
// offsets and extraIndices only need to be modified on a match (though they can be modified in any case)
private bool IndicesOverlap(IList<IExpression> mutated_indices, IList<IExpression> affected_indices, bool mutatesWithinOnly,
IReadOnlyDictionary<IVariableDeclaration, Bounds> boundsInMutated,
IReadOnlyDictionary<IVariableDeclaration, Bounds> boundsInAffected,
OffsetInfo offsets,
ICollection<IVariableDeclaration> extraIndices,
ICollection<IVariableDeclaration> matchedIndices)
private bool IndicesOverlap(
IList<IExpression> mutated_indices,
IList<IExpression> affected_indices,
bool mutatesWithinOnly,
IReadOnlyDictionary<IVariableDeclaration, Bounds> boundsInMutated,
IReadOnlyDictionary<IVariableDeclaration, Bounds> boundsInAffected,
OffsetInfo offsets,
ICollection<IVariableDeclaration> extraIndices,
ICollection<IVariableDeclaration> matchedIndices)
{
// if mutatesWithinOnly = false, then return false on mismatched literals
// if mutatesWithinOnly = true, then return false also if mutated index is wildcard and affected index is literal
@ -493,7 +496,7 @@ namespace Microsoft.ML.Probabilistic.Compiler
}
return false;
}
if(affectedStatement != null && mutatedStatement != null)
if (affectedStatement != null && mutatedStatement != null)
{
Set<IVariableDeclaration> localVarsInMutated = new Set<IVariableDeclaration>();
var bindingsInMutated = GetBindings(mutatedStatement, localVarsInMutated);

Просмотреть файл

@ -54,15 +54,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
/// <summary>Message to marginal of 'ModelSelector'</summary>
public Bernoulli ModelSelector_marginal_F;
public Bernoulli ModelSelector_selector_B;
@ -108,9 +108,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>The constant 'vBernoulli4'</summary>
public Bernoulli vBernoulli4;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPrecisionRateConstraints property</summary>
private DistributionStructArray<Gamma,double> weightPrecisionRateConstraints;
private DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints_field;
public Gamma WeightPrecisionRateRates_F_reduced;
public DistributionStructArray<Gamma,double> WeightPrecisionRates_depth0_F;
/// <summary>Message to marginal of 'WeightPrecisionRates'</summary>
@ -154,11 +154,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
this.Changed_FeatureCount_isDone = false;
@ -179,13 +179,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised = false;
@ -201,11 +201,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
@ -224,13 +224,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised = false;
@ -252,10 +252,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised = false;
@ -270,10 +270,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints
{
get {
return this.weightPrecisionRateConstraints;
return this.WeightPrecisionRateConstraints_field;
}
set {
this.weightPrecisionRateConstraints = value;
this.WeightPrecisionRateConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst9_isInitialised = false;
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = false;
@ -294,42 +294,42 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.ModelSelector_selector_cases_0_rep2_uses_B = new Bernoulli[this.featureCount][];
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisionRates_marginal_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep2_uses_B = new Bernoulli[this.FeatureCount][];
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisionRates_marginal_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
}
this.WeightPrecisionRateRates_F_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = GammaFromShapeAndRateOpBase.SampleAverageConditional(1.0, 1.0);
}
this.Weights_uses_F = new Gaussian[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_F = new Gaussian[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[FeatureRange] = new Gaussian[2];
this.Weights_uses_F[FeatureRange][1] = Gaussian.Uniform();
}
this.Weights_uses_B = new Gaussian[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B = new Gaussian[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange] = new Gaussian[2];
this.Weights_uses_B[FeatureRange][0] = Gaussian.Uniform();
this.Weights_uses_B[FeatureRange][1] = Gaussian.Uniform();
}
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.featureCount];
this.WeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.FeatureCount];
this.WeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_F[FeatureRange][1] = Gamma.Uniform();
}
this.WeightPrecisionRates_rep_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDefInit<Gamma>(this.WeightPrecisionRates_uses_F[FeatureRange][1]);
this.WeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
@ -339,21 +339,21 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.featureCount];
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.CommonWeightPrecision_rep_F = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.featureCount];
this.Weights_use_B = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_rep_F_marginal = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef = new Gaussian[this.featureCount];
this.Weights_rep_F = new Gaussian[this.featureCount][];
this.Weights_rep_B = new Gaussian[this.featureCount][];
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.featureCount];
this.ModelSelector_selector_cases_0_rep2_B = new Bernoulli[this.featureCount];
this.ModelSelector_selector_cases_0_rep5_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep5_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.CommonWeightPrecision_rep_F = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.FeatureCount];
this.Weights_use_B = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_rep_F_marginal = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef = new Gaussian[this.FeatureCount];
this.Weights_rep_F = new Gaussian[this.FeatureCount][];
this.Weights_rep_B = new Gaussian[this.FeatureCount][];
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.ModelSelector_selector_cases_0_rep2_B = new Bernoulli[this.FeatureCount];
this.ModelSelector_selector_cases_0_rep5_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep5_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep2_uses_B[FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep2_uses_B[FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep2_uses_B[FeatureRange][0] = Bernoulli.Uniform();
@ -369,14 +369,14 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.WeightPrecisionRates_depth0_F[FeatureRange] = Gamma.Uniform();
this.WeightPrecisionRates_marginal_F[FeatureRange] = Gamma.Uniform();
}
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_B[FeatureRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep4_uses_B = new Bernoulli[this.featureCount][];
this.Weights_depth0_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_uses_B = new Bernoulli[this.FeatureCount][];
this.Weights_depth0_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_uses_B[FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep4_uses_B[FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep4_uses_B[FeatureRange][0] = Bernoulli.Uniform();
@ -385,29 +385,29 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep4_B[FeatureRange] = Bernoulli.Uniform();
this.Weights_depth0_F[FeatureRange] = Gaussian.Uniform();
}
this.WeightPrecisionRates_rep_F_marginal = new Gamma[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F_marginal = new Gamma[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalInit<Gamma>(this.WeightPrecisionRates_uses_F[FeatureRange][1]);
}
this.WeightPrecisionRates_rep_F = new Gamma[this.featureCount][];
this.ModelSelector_selector_cases_0_rep7_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep7_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F = new Gamma[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep7_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep7_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep7_uses_B[FeatureRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep7_uses_B[FeatureRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep7_uses_B[FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep7_B[FeatureRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep10_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep10_B[FeatureRange] = Bernoulli.Uniform();
}
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = Gaussian.Uniform();
}
this.Changed_FeatureCount_isDone = true;
@ -419,12 +419,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.featureValues[InstanceRange][FeatureRange], 0.0);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], 0.0);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisionRates_rep_B[FeatureRange], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
this.WeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
}
@ -439,26 +439,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[FeatureRange], this.Weights_F[FeatureRange], 1, this.Weights_uses_F[FeatureRange][1]);
this.Weights_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[FeatureRange], this.Weights_uses_F[FeatureRange][1], this.Weights_rep_F_marginal[FeatureRange]);
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[FeatureRange][InstanceRange], this.Weights_rep_F_marginal[FeatureRange], InstanceRange, this.Weights_rep_F[FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_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.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_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[FeatureRange], this.Weights_rep_F[FeatureRange][InstanceRange], this.Weights_rep_B[FeatureRange][InstanceRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.Weights_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[FeatureRange], this.Weights_rep_B_toDef[FeatureRange]);
this.Weights_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[FeatureRange][1], this.Weights_rep_B_toDef[FeatureRange]);
@ -471,7 +471,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = GammaRatioOp_Laplace.BAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
@ -481,7 +481,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep2_uses_B[FeatureRange][0] = Bernoulli.FromLogOdds(GammaFromShapeAndRateOp_Laplace.LogEvidenceRatio(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_F[FeatureRange], this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]));
this.SharedWeightPrecisionRates_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 1, this.SharedWeightPrecisionRates_uses_F[FeatureRange][1]);
this.ModelSelector_selector_cases_0_rep2_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange]));
@ -494,12 +494,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.WeightPrecisionRates_marginal_F[FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gamma>(this.WeightPrecisionRates_use_B[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][1], this.WeightPrecisionRates_marginal_F[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[13] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep2_B, this.ModelSelector_selector_cases_0_uses_B[13]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_B[FeatureRange] = Bernoulli.FromLogOdds(GammaRatioOp_Laplace.LogEvidenceRatio(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]));
}
this.ModelSelector_selector_cases_0_uses_B[17] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep3_B, this.ModelSelector_selector_cases_0_uses_B[17]);
this.ModelSelector_selector_cases_0_uses_B[19] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F));
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_uses_B[FeatureRange][0] = Bernoulli.FromLogOdds(GaussianOp.LogEvidenceRatio(this.Weights_use_B[FeatureRange], 0.0, this.WeightPrecisions_F[FeatureRange], this.Weights_F[FeatureRange], this.WeightPrecisions_B[FeatureRange]));
this.Weights_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[FeatureRange], this.Weights_F[FeatureRange], 0, this.Weights_uses_F[FeatureRange][0]);
this.ModelSelector_selector_cases_0_rep4_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.Weights_uses_B[FeatureRange], this.Weights_F[FeatureRange], this.Weights_uses_F[FeatureRange]));
@ -507,40 +507,40 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_depth0_F[FeatureRange] = ArrayHelper.SetTo<Gaussian>(this.Weights_depth0_F[FeatureRange], this.Weights_uses_F[FeatureRange][0]);
}
this.ModelSelector_selector_cases_0_uses_B[20] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep4_B, this.ModelSelector_selector_cases_0_uses_B[20]);
this.ModelSelector_selector_cases_0_uses_B[26] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_depth0_F, this.weightConstraints));
this.ModelSelector_selector_cases_0_uses_B[26] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_depth0_F, this.WeightConstraints));
this.ModelSelector_selector_cases_0_uses_B[27] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep5_B, this.ModelSelector_selector_cases_0_uses_B[27]);
this.ModelSelector_selector_cases_0_uses_B[33] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_F, this.weightPrecisionRateConstraints));
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_uses_B[33] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_F, this.WeightPrecisionRateConstraints));
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal<Gamma>(this.WeightPrecisionRates_rep_B_toDef[FeatureRange], this.WeightPrecisionRates_uses_F[FeatureRange][1], this.WeightPrecisionRates_rep_F_marginal[FeatureRange]);
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange], this.WeightPrecisionRates_rep_F_marginal[FeatureRange], InstanceRange, this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange]);
this.WeightPrecisionRates_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gamma>(this.WeightPrecisionRates_rep_F_marginal[FeatureRange], this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange], this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange]);
this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange][FeatureRange] = Bernoulli.FromLogOdds(GaussianOpBase.LogEvidenceRatio(this.featureValues[InstanceRange][FeatureRange], 0.0, this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange]));
this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange][FeatureRange] = Bernoulli.FromLogOdds(GaussianOpBase.LogEvidenceRatio(this.FeatureValues[InstanceRange][FeatureRange], 0.0, this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange]));
}
this.ModelSelector_selector_cases_0_rep6_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange], this.ModelSelector_selector_cases_0_rep6_B[InstanceRange]);
}
this.ModelSelector_selector_cases_0_uses_B[34] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep6_B, this.ModelSelector_selector_cases_0_uses_B[34]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep7_uses_B[FeatureRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.WeightPrecisionRates_rep_B[FeatureRange], this.WeightPrecisionRates_uses_F[FeatureRange][1], this.WeightPrecisionRates_rep_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep7_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep7_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep7_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[35] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep7_B, this.ModelSelector_selector_cases_0_uses_B[35]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.Weights_rep_B[FeatureRange], this.Weights_uses_F[FeatureRange][1], this.Weights_rep_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep10_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep10_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[38] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_B, this.ModelSelector_selector_cases_0_uses_B[38]);
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep15_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep15_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.Labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
}
this.ModelSelector_selector_cases_0_uses_B[43] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep15_B, this.ModelSelector_selector_cases_0_uses_B[43]);
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.vBernoulli4, this.ModelSelector_marginal_F);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = VariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[FeatureRange], this.Weights_F[FeatureRange], this.Weights_marginal_F[FeatureRange]);
}
this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP12_isDone = true;
@ -553,7 +553,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons8_isDone&&((!initialise)||this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons8_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.Weights_F[FeatureRange] = GaussianOp.SampleAverageConditional(this.Weights_use_B[FeatureRange], 0.0, this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_B[FeatureRange]);
@ -568,7 +568,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.WeightPrecisionRates_use_B[FeatureRange]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_use_B[FeatureRange]);
}
@ -581,44 +581,44 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = Gamma.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F[FeatureRange] = new Gamma[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F[FeatureRange] = new Gamma[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_F[FeatureRange][InstanceRange] = Gamma.Uniform();
}
this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange] = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange] = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep6_rep_B[InstanceRange][FeatureRange] = Bernoulli.Uniform();
}
}
@ -632,8 +632,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isDone&&((!initialise)||this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
@ -648,7 +648,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_WeightConst3_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[FeatureRange] = Gaussian.Uniform();
this.WeightPrecisions_B[FeatureRange] = Gamma.Uniform();
this.WeightPrecisions_F[FeatureRange] = Gamma.Uniform();
@ -676,8 +676,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[FeatureRange][0], this.weightConstraints[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[FeatureRange][0], this.WeightConstraints[FeatureRange]);
}
this.Changed_FeatureCount_WeightConstraints_isDone = true;
}
@ -688,8 +688,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.weightPrecisionRateConstraints[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.WeightPrecisionRateConstraints[FeatureRange]);
}
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = true;
}
@ -700,31 +700,31 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.ModelSelector_selector_cases_0_rep6_rep_B = new Bernoulli[this.instanceCount][];
this.ModelSelector_selector_cases_0_rep6_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep6_rep_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep6_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep6_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep15_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep15_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep15_B[InstanceRange] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_isDone = true;

Просмотреть файл

@ -54,15 +54,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
public Gaussian[] NoisyScore_F;
/// <summary>Message from use of 'NoisyScore'</summary>
public Gaussian[] NoisyScore_use_B;
@ -80,9 +80,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Messages to uses of 'SharedWeightPrecisionRates_use'</summary>
public Gamma[][] SharedWeightPrecisionRates_uses_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPrecisionRateConstraints property</summary>
private DistributionStructArray<Gamma,double> weightPrecisionRateConstraints;
private DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints_field;
public Gamma WeightPrecisionRateRates_F_reduced;
public Gamma[][] WeightPrecisionRates_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gamma&gt;</summary>
@ -119,11 +119,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
this.Changed_FeatureCount_isDone = false;
@ -144,13 +144,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised = false;
@ -166,11 +166,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
@ -189,13 +189,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised = false;
@ -217,10 +217,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
this.Changed_FeatureCount_WeightConstraints_isDone = false;
@ -235,10 +235,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints
{
get {
return this.weightPrecisionRateConstraints;
return this.WeightPrecisionRateConstraints_field;
}
set {
this.weightPrecisionRateConstraints = value;
this.WeightPrecisionRateConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_InstanceCount_Labels_WeightConst3_isInitialised = false;
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = false;
@ -259,29 +259,29 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.WeightPrecisionRateRates_F_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.featureCount);
if (this.featureCount>0) {
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = GammaFromShapeAndRateOpBase.SampleAverageConditional(1.0, 1.0);
}
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
}
this.WeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.featureCount];
this.WeightPrecisionRates_rep_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.FeatureCount];
this.WeightPrecisionRates_rep_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
this.WeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
@ -293,28 +293,28 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.featureCount];
this.Weights_uses_B = new Gaussian[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.Weights_uses_B = new Gaussian[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange] = new Gaussian[2];
this.Weights_uses_B[FeatureRange][0] = Gaussian.Uniform();
this.Weights_uses_B[FeatureRange][1] = Gaussian.Uniform();
}
this.Weights_uses_F = new Gaussian[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_F = new Gaussian[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[FeatureRange] = new Gaussian[2];
this.Weights_uses_F[FeatureRange][1] = Gaussian.Uniform();
}
this.Weights_rep_F_marginal = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef = new Gaussian[this.featureCount];
this.Weights_rep_F = new Gaussian[this.featureCount][];
this.Weights_rep_B = new Gaussian[this.featureCount][];
this.Weights_use_B = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.featureCount];
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F_marginal = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef = new Gaussian[this.FeatureCount];
this.Weights_rep_F = new Gaussian[this.FeatureCount][];
this.Weights_rep_B = new Gaussian[this.FeatureCount][];
this.Weights_use_B = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.FeatureCount];
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = Gaussian.Uniform();
}
this.Changed_FeatureCount_isDone = true;
@ -326,12 +326,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.featureValues[InstanceRange][FeatureRange], 0.0);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], 0.0);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisionRates_rep_B[FeatureRange], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
this.WeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
}
@ -346,26 +346,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[FeatureRange], this.Weights_F[FeatureRange], 1, this.Weights_uses_F[FeatureRange][1]);
this.Weights_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[FeatureRange], this.Weights_uses_F[FeatureRange][1], this.Weights_rep_F_marginal[FeatureRange]);
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[FeatureRange][InstanceRange], this.Weights_rep_F_marginal[FeatureRange], InstanceRange, this.Weights_rep_F[FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_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.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_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[FeatureRange], this.Weights_rep_F[FeatureRange][InstanceRange], this.Weights_rep_B[FeatureRange][InstanceRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.SharedWeightPrecisionRates_F[FeatureRange] = GammaFromShapeAndRateOp_Laplace.SampleAverageConditional(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
@ -378,7 +378,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = GammaRatioOp_Laplace.BAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
@ -388,7 +388,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = VariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[FeatureRange], this.Weights_F[FeatureRange], this.Weights_marginal_F[FeatureRange]);
}
this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP12_isDone = true;
@ -401,7 +401,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons11_isDone&&((!initialise)||this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons11_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.Weights_F[FeatureRange] = GaussianOp.SampleAverageConditional(this.Weights_use_B[FeatureRange], 0.0, this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_B[FeatureRange]);
@ -416,7 +416,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.WeightPrecisionRates_use_B[FeatureRange]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_use_B[FeatureRange]);
}
@ -429,32 +429,32 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = Gamma.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange] = new Gaussian[this.InstanceCount];
}
this.Changed_FeatureCount_InstanceCount_isDone = true;
}
@ -466,8 +466,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isDone&&((!initialise)||this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
@ -482,7 +482,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_WeightConst2_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_WeightConst2_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[FeatureRange] = Gaussian.Uniform();
this.SharedWeightPrecisionRates_F[FeatureRange] = Gamma.Uniform();
this.WeightPrecisions_B[FeatureRange] = Gamma.Uniform();
@ -510,8 +510,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[FeatureRange][0], this.weightConstraints[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[FeatureRange][0], this.WeightConstraints[FeatureRange]);
}
this.Changed_FeatureCount_WeightConstraints_isDone = true;
}
@ -522,8 +522,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.weightPrecisionRateConstraints[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.WeightPrecisionRateConstraints[FeatureRange]);
}
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = true;
}
@ -534,24 +534,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Changed_InstanceCount_isDone = true;
}

Просмотреть файл

@ -77,7 +77,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Changed_numberOfIterationsDecreased_Init_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_6 has performed initialisation. Set this to false to force re-execution of Changed_numberOfIterationsDecreased_Init_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_6</summary>
public bool Changed_numberOfIterationsDecreased_Init_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_6_isInitialised;
/// <summary>Field backing the ClassCount property</summary>
private int classCount;
private int ClassCount_field;
public Gamma CommonWeightPrecision_F;
public Gamma[] CommonWeightPrecision_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gamma&gt;</summary>
@ -88,15 +88,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private int[] labels;
private int[] Labels_field;
public Gaussian[][][] MaxNoisyScore_0__B;
public Gaussian[][][] MaxNoisyScore_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
@ -135,9 +135,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[][][] vbool22;
public Gaussian[][][] vdouble243_B;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightConstraints;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints_field;
/// <summary>Field backing the WeightPrecisionRateConstraints property</summary>
private DistributionStructArray<Gamma,double> weightPrecisionRateConstraints;
private DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints_field;
public Gamma WeightPrecisionRateRates_F_reduced;
public Gamma[][] WeightPrecisionRates_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gamma&gt;</summary>
@ -179,11 +179,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int ClassCount
{
get {
return this.classCount;
return this.ClassCount_field;
}
set {
if (this.classCount!=value) {
this.classCount = value;
if (this.ClassCount_field!=value) {
this.ClassCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
@ -210,11 +210,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isInitialised = false;
@ -243,13 +243,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isInitialised = false;
@ -271,11 +271,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
@ -303,13 +303,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised = false;
@ -338,10 +338,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isInitialised = false;
@ -362,10 +362,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints
{
get {
return this.weightPrecisionRateConstraints;
return this.WeightPrecisionRateConstraints_field;
}
set {
this.weightPrecisionRateConstraints = value;
this.WeightPrecisionRateConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isInitialised = false;
@ -392,18 +392,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_isDone) {
return ;
}
this.SharedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_B = new Gaussian[this.classCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_F = new Gaussian[this.classCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.classCount][];
this.Weights_rep_B_toDef = new Gaussian[this.classCount][];
this.Weights_rep_F = new Gaussian[this.classCount][][];
this.Weights_rep_B = new Gaussian[this.classCount][][];
this.SharedWeights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.SharedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.ClassCount][];
this.Weights_rep_B_toDef = new Gaussian[this.ClassCount][];
this.Weights_rep_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_B = new Gaussian[this.ClassCount][][];
this.SharedWeights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Changed_ClassCount_isDone = true;
}
@ -413,43 +413,43 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.SharedWeights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.SharedWeights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_rep_F[FeatureRange] = new Gamma[this.classCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_F[FeatureRange] = new Gamma[this.ClassCount];
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_uses_B[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_B[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
}
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.featureCount][];
this.SharedWeights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.FeatureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.FeatureCount][];
this.SharedWeights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_rep_B[FeatureRange] = new Gamma[this.classCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_B[FeatureRange] = new Gamma[this.ClassCount];
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_marginal_F[ClassRange][_iv] = Gaussian.Uniform();
}
}
@ -464,65 +464,44 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisions_rep_B[FeatureRange], this.WeightPrecisions_rep_B_toDef[FeatureRange]);
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.SharedWeightPrecisionRates_F[FeatureRange] = GammaFromShapeAndRateOp_Laplace.SampleAverageConditional(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.CommonWeightPrecision_rep_B[FeatureRange] = GammaRatioOp_Laplace.AAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal<Gamma>(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_rep_F_marginal[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_F[FeatureRange][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.WeightPrecisions_rep_B[FeatureRange][ClassRange], this.WeightPrecisions_rep_F_marginal[FeatureRange], ClassRange, this.WeightPrecisions_rep_F[FeatureRange][ClassRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = GammaRatioOp_Laplace.BAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_use_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeights_F[ClassRange][FeatureRange] = GaussianOp.SampleAverageConditional(this.SharedWeights_use_B[ClassRange][FeatureRange], 0.0, this.WeightPrecisions_rep_F[FeatureRange][ClassRange], this.WeightPrecisions_rep_B[FeatureRange][ClassRange]);
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.SharedWeights_F[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.SharedWeights_F[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -530,36 +509,39 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[ClassRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange]);
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.SharedWeightPrecisionRates_F[FeatureRange] = GammaFromShapeAndRateOp_Laplace.SampleAverageConditional(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_uses_B[ClassRange][FeatureRange][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange][1], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_use_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange]);
@ -567,10 +549,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.WeightPrecisions_rep_B[FeatureRange][ClassRange] = GaussianOp.PrecisionAverageConditional(this.SharedWeights_use_B[ClassRange][FeatureRange], Gaussian.PointMass(0.0), this.WeightPrecisions_rep_F[FeatureRange][ClassRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisions_rep_B[FeatureRange], this.WeightPrecisions_rep_B_toDef[FeatureRange]);
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.CommonWeightPrecision_rep_B[FeatureRange] = GammaRatioOp_Laplace.AAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = GammaRatioOp_Laplace.BAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_use_B[FeatureRange]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
@ -583,27 +579,44 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh22_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
@ -612,13 +625,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_uses_B[ClassRange][FeatureRange][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange][1], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_use_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange]);
@ -626,6 +639,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.WeightPrecisions_rep_B[FeatureRange][ClassRange] = GaussianOp.PrecisionAverageConditional(this.SharedWeights_use_B[ClassRange][FeatureRange], Gaussian.PointMass(0.0), this.WeightPrecisions_rep_F[FeatureRange][ClassRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisions_rep_B[FeatureRange], this.WeightPrecisions_rep_B_toDef[FeatureRange]);
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh22_isDone = true;
}
@ -636,8 +652,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr21_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr21_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
@ -653,19 +669,19 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecis20_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecis20_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_rep_F[FeatureRange][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.WeightPrecisions_rep_B[FeatureRange][ClassRange], this.WeightPrecisions_rep_F_marginal[FeatureRange], ClassRange, this.WeightPrecisions_rep_F[FeatureRange][ClassRange]);
this.SharedWeights_F[ClassRange][FeatureRange] = GaussianOp.SampleAverageConditional(this.SharedWeights_use_B[ClassRange][FeatureRange], 0.0, this.WeightPrecisions_rep_F[FeatureRange][ClassRange], this.WeightPrecisions_rep_B[FeatureRange][ClassRange]);
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.SharedWeights_F[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.SharedWeights_F[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
}
}
@ -679,20 +695,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
this.Changed_ClassCount_FeatureCount_InstanceCount_isDone = true;
@ -705,9 +721,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_13_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_13_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
@ -726,25 +742,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_5_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_5_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeights_F[ClassRange][FeatureRange] = Gaussian.Uniform();
this.WeightPrecisions_rep_F[FeatureRange][ClassRange] = Gamma.Uniform();
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_uses_B[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.SharedWeights_use_B[ClassRange][FeatureRange] = Gaussian.Uniform();
@ -761,9 +777,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.weightConstraints[ClassRange][_iv]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.WeightConstraints[ClassRange][_iv]);
}
}
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = true;
@ -775,13 +791,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
}
this.Changed_ClassCount_InstanceCount_isDone = true;
}
@ -792,66 +808,66 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.vdouble243_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.vdouble243_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.vbool22[InstanceRange] = new bool[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool22[InstanceRange][ClassMaxNoisyScore] = new bool[this.classCount];
this.vbool22[InstanceRange] = new bool[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool22[InstanceRange][ClassMaxNoisyScore] = new bool[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vbool22[InstanceRange][ClassMaxNoisyScore][ClassRange] = true;
Constrain.Equal<bool>(true, this.vbool22[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -870,16 +886,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
@ -895,20 +911,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = Gaussian.Uniform();
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
}
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_18_isDone = true;
@ -922,8 +924,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_16_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.Scores_B[InstanceRange][ClassRange] = Gaussian.Uniform();
@ -940,26 +942,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
this.WeightPrecisionRateRates_F_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.featureCount);
if (this.featureCount>0) {
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = GammaFromShapeAndRateOpBase.SampleAverageConditional(1.0, 1.0);
}
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
}
this.WeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.featureCount];
this.WeightPrecisionRates_rep_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisionRates_rep_B_toDef = new Gamma[this.FeatureCount];
this.WeightPrecisionRates_rep_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
this.WeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
@ -971,17 +973,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.featureCount];
this.WeightPrecisions_rep_F_marginal = new Gamma[this.featureCount];
this.WeightPrecisions_rep_B_toDef = new Gamma[this.featureCount];
this.WeightPrecisions_rep_F = new Gamma[this.featureCount][];
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.WeightPrecisions_rep_B = new Gamma[this.featureCount][];
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.featureCount];
if (this.featureCount>0) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.WeightPrecisions_rep_F_marginal = new Gamma[this.FeatureCount];
this.WeightPrecisions_rep_B_toDef = new Gamma[this.FeatureCount];
this.WeightPrecisions_rep_F = new Gamma[this.FeatureCount][];
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.WeightPrecisions_rep_B = new Gamma[this.FeatureCount][];
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.FeatureCount];
if (this.FeatureCount>0) {
this.TransposedWeightSums_reduced = 0.0;
Constrain.Equal<double>(this.TransposedWeightSums_reduced, 0.0);
}
@ -994,12 +996,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.featureValues[InstanceRange][FeatureRange], 0.0);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = GaussianOpBase.PrecisionAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], 0.0);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef<Gamma>(this.WeightPrecisionRates_rep_B[FeatureRange], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
this.WeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_rep_B_toDef[FeatureRange]);
}
@ -1013,7 +1015,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons19_isDone&&((!initialise)||this.Changed_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightPrecisionRateCons19_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal<Gamma>(this.WeightPrecisions_rep_B_toDef[FeatureRange], this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_rep_F_marginal[FeatureRange]);
@ -1028,7 +1030,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.WeightPrecisionRates_use_B[FeatureRange]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_use_B[FeatureRange]);
}
@ -1041,11 +1043,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange] = new Gamma[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_rep_B[FeatureRange][InstanceRange] = Gamma.Uniform();
}
}
@ -1059,7 +1061,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_Init_ClassCount_FeatureValues_InstanceCount_Labels_2_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_Init_ClassCount_FeatureValues_InstanceCount_Labels_2_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F[FeatureRange] = Gamma.Uniform();
this.WeightPrecisions_F[FeatureRange] = Gamma.Uniform();
this.SharedWeightPrecisionRates_use_B[FeatureRange] = Gamma.Uniform();
@ -1084,8 +1086,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.weightPrecisionRateConstraints[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.WeightPrecisionRateConstraints[FeatureRange]);
}
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = true;
}
@ -1096,23 +1098,23 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.instanceCount][][];
this.vdouble243_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.instanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.instanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.instanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.vbool22 = new bool[this.instanceCount][][];
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.InstanceCount][][];
this.vdouble243_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.vbool22 = new bool[this.InstanceCount][][];
this.Changed_InstanceCount_isDone = true;
}

Просмотреть файл

@ -54,21 +54,21 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionRefArray<DistributionStructArray<Gamma,double>,double[]> IndexedWeightPrecisionRates_B;
public DistributionStructArray<Gaussian,double>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
/// <summary>Message to marginal of 'ModelSelector'</summary>
public Bernoulli ModelSelector_marginal_F;
public Bernoulli ModelSelector_selector_B;
@ -112,9 +112,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>The constant 'vBernoulli5'</summary>
public Bernoulli vBernoulli5;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPrecisionRateConstraints property</summary>
private DistributionStructArray<Gamma,double> weightPrecisionRateConstraints;
private DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints_field;
public Gamma WeightPrecisionRateRates_F_reduced;
public DistributionStructArray<Gamma,double> WeightPrecisionRates_depth0_B;
public DistributionStructArray<Gamma,double> WeightPrecisionRates_depth0_F;
@ -150,7 +150,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double>[] Weights_uses_F;
public double Zero_reduced;
/// <summary>Field backing the ZeroFeatureValueInstanceCounts property</summary>
private double[] zeroFeatureValueInstanceCounts;
private double[] ZeroFeatureValueInstanceCounts_field;
#endregion
#region Properties
@ -158,11 +158,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -181,13 +181,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -201,13 +201,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
@ -222,11 +222,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -244,13 +244,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -266,13 +266,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -294,10 +294,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -312,10 +312,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints
{
get {
return this.weightPrecisionRateConstraints;
return this.WeightPrecisionRateConstraints_field;
}
set {
this.weightPrecisionRateConstraints = value;
this.WeightPrecisionRateConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -330,13 +330,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[] ZeroFeatureValueInstanceCounts
{
get {
return this.zeroFeatureValueInstanceCounts;
return this.ZeroFeatureValueInstanceCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.featureCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.featureCount)+" was expected for variable \'ZeroFeatureValueInstanceCounts\'");
if ((value!=null)&&(value.Length!=this.FeatureCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.FeatureCount)+" was expected for variable \'ZeroFeatureValueInstanceCounts\'");
}
this.zeroFeatureValueInstanceCounts = value;
this.ZeroFeatureValueInstanceCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised = false;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins8_isInitialised = false;
@ -356,102 +356,102 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.ModelSelector_selector_cases_0_rep3_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.featureCount];
this.Weights_uses_B[1] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.FeatureCount];
this.Weights_uses_B[1] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[1][FeatureRange] = Gaussian.Uniform();
}
this.Weights_uses_F[1] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_F[1] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = Gaussian.Uniform();
}
this.Weights_B = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_B = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_B[FeatureRange] = Gaussian.Uniform();
}
this.Weights_uses_B[0] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B[0] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[0][FeatureRange] = Gaussian.Uniform();
}
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = default(Gamma);
}
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisionRateRates_F_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = GammaFromShapeAndRateOpBase.SampleAverageConditional(1.0, 1.0);
}
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F[FeatureRange] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
this.SharedWeightPrecisionRates_uses_F[FeatureRange][1] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.featureCount];
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.FeatureCount];
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_F[FeatureRange] = Gamma.Uniform();
}
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[FeatureRange] = Gaussian.Uniform();
}
this.WeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_F[FeatureRange][0] = Gamma.Uniform();
}
this.WeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
this.WeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
this.WeightPrecisionRates_rpt_B_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRates_rpt_B_reduced = GaussianOpBase.PrecisionAverageConditional(0.0, 0.0);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
this.WeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_F[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_uses_F[1] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[1] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[1][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_uses_B[0] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[0] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[0][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_marginal_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_marginal_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_marginal_F[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_uses_B[1] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[1] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[1][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_B[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B[FeatureRange] = Gamma.Uniform();
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][1] = Bernoulli.Uniform();
@ -459,25 +459,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][2] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep3_B[FeatureRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_B[FeatureRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep5_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep5_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep5_B[FeatureRange] = Bernoulli.Uniform();
}
this.Weights_uses_F[0] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_F[0] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[0][FeatureRange] = Gaussian.Uniform();
}
this.ModelSelector_selector_cases_0_rep6_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep10_rpt_B = new Bernoulli[this.featureCount];
this.WeightPrecisionRates_rpt_F = new Gamma[this.featureCount];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.featureCount];
this.ModelSelector_selector_cases_0_rep10_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep6_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep6_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep10_rpt_B = new Bernoulli[this.FeatureCount];
this.WeightPrecisionRates_rpt_F = new Gamma[this.FeatureCount];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.FeatureCount];
this.ModelSelector_selector_cases_0_rep10_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep6_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep6_uses_B[FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep6_uses_B[FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep6_uses_B[FeatureRange][0] = Bernoulli.Uniform();
@ -492,24 +492,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][2] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep10_B[FeatureRange] = Bernoulli.Uniform();
}
this.WeightPrecisionRates_depth0_uses_F[0] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[0] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[0][FeatureRange] = Gamma.Uniform();
}
this.Zero_reduced = default(double);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.Zero_reduced = 0.0;
}
this.ModelSelector_selector_cases_0_rep11_rpt_B_reduced = default(Bernoulli);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.ModelSelector_selector_cases_0_rep11_rpt_B_reduced = Bernoulli.FromLogOdds(ConstrainEqualOp<double>.LogEvidenceRatio(this.Zero_reduced, 0.0));
}
this.ModelSelector_selector_cases_0_rep11_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep11_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep11_B[FeatureRange] = Bernoulli.Uniform();
}
this.WeightPrecisionRates_marginal_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_marginal_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_marginal_F[FeatureRange] = Gamma.Uniform();
}
this.Changed_FeatureCount_isDone = true;
@ -525,7 +525,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; 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);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.SharedWeightPrecisionRates_F[FeatureRange] = GammaFromShapeAndRateOp_Laplace.SampleAverageConditional(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
@ -534,7 +534,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_B[FeatureRange] = GaussianOp.PrecisionAverageConditional(this.Weights_B[FeatureRange], Gaussian.PointMass(0.0), this.WeightPrecisions_F[FeatureRange]);
@ -542,22 +542,22 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.Weights_F, 1, this.Weights_uses_F[1]);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalIncrementArray<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.Weights_uses_B[1], this.Weights_marginal_F);
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]);
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.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]);
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.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);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_B_FeatureRange__Q[FeatureRange] = GammaRatioOp_Laplace.Q(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = GammaRatioOp_Laplace.BAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 1, this.SharedWeightPrecisionRates_uses_F[FeatureRange][1]);
@ -565,10 +565,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.WeightPrecisionRates_depth0_F[FeatureRange] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_depth0_F[FeatureRange], this.WeightPrecisionRates_uses_F[FeatureRange][0]);
}
this.WeightPrecisionRates_depth0_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_F, 1, this.WeightPrecisionRates_depth0_uses_F[1]);
this.WeightPrecisionRates_depth0_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.IndexedWeightPrecisionRates_B, this.featureIndexes, this.WeightPrecisionRates_depth0_marginal_F);
this.WeightPrecisionRates_depth0_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.IndexedWeightPrecisionRates_B, this.FeatureIndexes, this.WeightPrecisionRates_depth0_marginal_F);
this.WeightPrecisionRates_depth0_uses_B[1] = JaggedSubarrayWithMarginalOp<double>.ArrayAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.WeightPrecisionRates_depth0_marginal_F, this.WeightPrecisionRates_depth0_uses_B[1]);
this.WeightPrecisionRates_depth0_B = ReplicateOp_NoDivide.DefAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_B);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.WeightPrecisionRates_depth0_B[FeatureRange]);
this.WeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.WeightPrecisionRates_use_B[FeatureRange]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_use_B[FeatureRange]);
@ -577,60 +577,60 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
this.WeightPrecisionRates_depth0_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalIncrementArray<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.WeightPrecisionRates_depth0_uses_B[1], this.WeightPrecisionRates_depth0_marginal_F);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][0] = Bernoulli.FromLogOdds(GammaFromShapeAndRateOp_Laplace.LogEvidenceRatio(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_F[FeatureRange], this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]));
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep3_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep3_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[15] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep3_B, this.ModelSelector_selector_cases_0_uses_B[15]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_B[FeatureRange] = Bernoulli.FromLogOdds(GammaRatioOp_Laplace.LogEvidenceRatio(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0], this.WeightPrecisions_F[FeatureRange], this.WeightPrecisions_B_FeatureRange__Q[FeatureRange]));
}
this.ModelSelector_selector_cases_0_uses_B[19] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep4_B, this.ModelSelector_selector_cases_0_uses_B[19]);
this.ModelSelector_selector_cases_0_uses_B[21] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F));
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep5_B[FeatureRange] = Bernoulli.FromLogOdds(GaussianOp.LogEvidenceRatio(this.Weights_B[FeatureRange], 0.0, this.WeightPrecisions_F[FeatureRange], this.Weights_F[FeatureRange], this.WeightPrecisions_B[FeatureRange]));
}
this.ModelSelector_selector_cases_0_uses_B[22] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep5_B, this.ModelSelector_selector_cases_0_uses_B[22]);
this.Weights_uses_F[0] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.Weights_F, 0, this.Weights_uses_F[0]);
this.ModelSelector_selector_cases_0_uses_B[24] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.Weights_F, this.Weights_uses_F));
this.ModelSelector_selector_cases_0_uses_B[25] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[0], this.weightConstraints));
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_uses_B[25] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[0], this.WeightConstraints));
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][1], 1, this.WeightPrecisionRates_uses_F[FeatureRange][1]);
this.ModelSelector_selector_cases_0_rep6_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][1], this.WeightPrecisionRates_uses_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep6_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep6_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep6_B[FeatureRange]);
this.WeightPrecisionRates_rpt_F[FeatureRange] = PowerPlateOp.EnterAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.WeightPrecisionRates_uses_F[FeatureRange][1], this.zeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_rpt_F[FeatureRange]);
this.WeightPrecisionRates_rpt_F[FeatureRange] = PowerPlateOp.EnterAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.WeightPrecisionRates_uses_F[FeatureRange][1], this.ZeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_rpt_F[FeatureRange]);
this.ModelSelector_selector_cases_0_rep10_rpt_B[FeatureRange] = Bernoulli.FromLogOdds(GaussianOpBase.LogEvidenceRatio(0.0, 0.0, this.WeightPrecisionRates_rpt_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][0] = PowerPlateOp.ValueAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_rpt_B[FeatureRange], this.zeroFeatureValueInstanceCounts[FeatureRange], this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][0]);
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(PowerPlateOp.LogEvidenceRatio<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.WeightPrecisionRates_uses_F[FeatureRange][1], this.zeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_rpt_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][0] = PowerPlateOp.ValueAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_rpt_B[FeatureRange], this.ZeroFeatureValueInstanceCounts[FeatureRange], this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][0]);
this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange][2] = Bernoulli.FromLogOdds(PowerPlateOp.LogEvidenceRatio<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.WeightPrecisionRates_uses_F[FeatureRange][1], this.ZeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_rpt_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep10_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep10_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[26] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep6_B, this.ModelSelector_selector_cases_0_uses_B[26]);
this.WeightPrecisionRates_depth0_uses_F[0] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_F, 0, this.WeightPrecisionRates_depth0_uses_F[0]);
this.ModelSelector_selector_cases_0_uses_B[33] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_F, this.WeightPrecisionRates_depth0_uses_F));
this.ModelSelector_selector_cases_0_uses_B[34] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[0], this.weightPrecisionRateConstraints));
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange] = JaggedSubarrayWithMarginalOp<double>.ItemsAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.IndexedWeightPrecisionRates_B[InstanceRange], this.WeightPrecisionRates_depth0_uses_F[1], this.WeightPrecisionRates_depth0_marginal_F, this.featureIndexes, InstanceRange, this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange]);
this.ModelSelector_selector_cases_0_uses_B[34] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[0], this.WeightPrecisionRateConstraints));
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange] = JaggedSubarrayWithMarginalOp<double>.ItemsAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.IndexedWeightPrecisionRates_B[InstanceRange], this.WeightPrecisionRates_depth0_uses_F[1], this.WeightPrecisionRates_depth0_marginal_F, this.FeatureIndexes, InstanceRange, this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange]);
}
this.ModelSelector_selector_cases_0_uses_B[37] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp<double>.LogEvidenceRatio<Gamma>(this.IndexedWeightPrecisionRates_B, this.WeightPrecisionRates_depth0_uses_F[1], this.featureIndexes, this.WeightPrecisionRates_FeatureIndexes_F));
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange][InstanceFeatureRanges] = Bernoulli.FromLogOdds(GaussianOpBase.LogEvidenceRatio(this.featureValues[InstanceRange][InstanceFeatureRanges], 0.0, this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]));
this.ModelSelector_selector_cases_0_uses_B[37] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp<double>.LogEvidenceRatio<Gamma>(this.IndexedWeightPrecisionRates_B, this.WeightPrecisionRates_depth0_uses_F[1], this.FeatureIndexes, this.WeightPrecisionRates_FeatureIndexes_F));
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange][InstanceFeatureRanges] = Bernoulli.FromLogOdds(GaussianOpBase.LogEvidenceRatio(this.FeatureValues[InstanceRange][InstanceFeatureRanges], 0.0, this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]));
}
this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange], this.ModelSelector_selector_cases_0_rep8_B[InstanceRange]);
}
this.ModelSelector_selector_cases_0_uses_B[39] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep8_B, this.ModelSelector_selector_cases_0_uses_B[39]);
this.ModelSelector_selector_cases_0_uses_B[41] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_B, this.ModelSelector_selector_cases_0_uses_B[41]);
this.ModelSelector_selector_cases_0_uses_B[46] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp<double>.LogEvidenceRatio<Gaussian>(this.IndexedWeights_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_rep20_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
this.ModelSelector_selector_cases_0_uses_B[46] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp<double>.LogEvidenceRatio<Gaussian>(this.IndexedWeights_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_rep20_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.Labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
}
this.ModelSelector_selector_cases_0_uses_B[54] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep20_B, this.ModelSelector_selector_cases_0_uses_B[54]);
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.vBernoulli5, this.ModelSelector_marginal_F);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_marginal_F[FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gamma>(this.WeightPrecisionRates_use_B[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][1], this.WeightPrecisionRates_marginal_F[FeatureRange]);
}
this.Changed_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberO12_isDone = true;
@ -643,7 +643,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_6_isDone&&((!initialise)||this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_6_isInitialised)) {
return ;
}
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_marginal_F);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.FeatureIndexes, this.Weights_marginal_F);
this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_6_isDone = true;
this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_6_isInitialised = true;
}
@ -655,7 +655,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_InstanceCount_Ins2_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_InstanceCount_Ins2_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[1][FeatureRange] = Gaussian.Uniform();
this.SharedWeightPrecisionRates_use_B[FeatureRange] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
@ -675,7 +675,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightConstraints_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Changed_FeatureCount_WeightConstraints_isDone = true;
}
@ -685,7 +685,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
this.WeightPrecisionRates_depth0_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B[0], this.weightPrecisionRateConstraints);
this.WeightPrecisionRates_depth0_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B[0], this.WeightPrecisionRateConstraints);
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = true;
}
@ -695,9 +695,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_ZeroFeatureValueInstanceCounts_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][1] = PowerPlateOp.ValueAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.zeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_uses_B[FeatureRange][1]);
this.ModelSelector_selector_cases_0_rep11_B[FeatureRange] = PowerPlateOp.ValueAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep11_rpt_B_reduced, this.zeroFeatureValueInstanceCounts[FeatureRange], this.ModelSelector_selector_cases_0_rep11_B[FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][1] = PowerPlateOp.ValueAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.ZeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_uses_B[FeatureRange][1]);
this.ModelSelector_selector_cases_0_rep11_B[FeatureRange] = PowerPlateOp.ValueAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep11_rpt_B_reduced, this.ZeroFeatureValueInstanceCounts[FeatureRange], this.ModelSelector_selector_cases_0_rep11_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[42] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep11_B, this.ModelSelector_selector_cases_0_uses_B[42]);
this.Changed_FeatureCount_ZeroFeatureValueInstanceCounts_isDone = true;
@ -709,9 +709,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = GaussianOpBase.PrecisionAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], 0.0);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = GaussianOpBase.PrecisionAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], 0.0);
}
}
this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone = true;
@ -723,35 +723,35 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.IndexedWeightPrecisionRates_B = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.instanceCount);
this.WeightPrecisionRates_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.instanceCount);
this.ModelSelector_selector_cases_0_rep8_rep_B = new Bernoulli[this.instanceCount][];
this.ModelSelector_selector_cases_0_rep8_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.IndexedWeightPrecisionRates_B = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.InstanceCount);
this.WeightPrecisionRates_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.InstanceCount);
this.ModelSelector_selector_cases_0_rep8_rep_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep8_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep20_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep20_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep20_B[InstanceRange] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_isDone = true;
@ -763,30 +763,30 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeightPrecisionRates_B[InstanceRange] = new DistributionStructArray<Gamma,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange] = new DistributionStructArray<Gamma,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = Gamma.Uniform();
}
this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gamma,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gamma,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.WeightPrecisionRates_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gamma.Uniform();
}
this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange] = new Bernoulli[this.instanceFeatureCounts[InstanceRange]];
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange] = new Bernoulli[this.InstanceFeatureCounts[InstanceRange]];
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.ModelSelector_selector_cases_0_rep8_rep_B[InstanceRange][InstanceFeatureRanges] = Bernoulli.Uniform();
}
}
@ -800,8 +800,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isDone&&((!initialise)||this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd5_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}

Просмотреть файл

@ -54,21 +54,21 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionRefArray<DistributionStructArray<Gamma,double>,double[]> IndexedWeightPrecisionRates_B;
public DistributionStructArray<Gaussian,double>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
public Gaussian[] NoisyScore_F;
/// <summary>Message from use of 'NoisyScore'</summary>
public Gaussian[] NoisyScore_use_B;
@ -86,9 +86,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Messages to uses of 'SharedWeightPrecisionRates_use'</summary>
public Gamma[][] SharedWeightPrecisionRates_uses_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPrecisionRateConstraints property</summary>
private DistributionStructArray<Gamma,double> weightPrecisionRateConstraints;
private DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints_field;
public Gamma WeightPrecisionRateRates_F_reduced;
public DistributionStructArray<Gamma,double> WeightPrecisionRates_depth0_B;
public DistributionStructArray<Gamma,double> WeightPrecisionRates_depth0_F;
@ -120,7 +120,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double>[] Weights_uses_F;
public double Zero_reduced;
/// <summary>Field backing the ZeroFeatureValueInstanceCounts property</summary>
private double[] zeroFeatureValueInstanceCounts;
private double[] ZeroFeatureValueInstanceCounts_field;
#endregion
#region Properties
@ -128,11 +128,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -151,13 +151,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -171,13 +171,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -192,11 +192,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_isDone = false;
@ -214,13 +214,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -236,13 +236,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -264,10 +264,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -282,10 +282,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gamma,double> WeightPrecisionRateConstraints
{
get {
return this.weightPrecisionRateConstraints;
return this.WeightPrecisionRateConstraints_field;
}
set {
this.weightPrecisionRateConstraints = value;
this.WeightPrecisionRateConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -300,13 +300,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[] ZeroFeatureValueInstanceCounts
{
get {
return this.zeroFeatureValueInstanceCounts;
return this.ZeroFeatureValueInstanceCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.featureCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.featureCount)+" was expected for variable \'ZeroFeatureValueInstanceCounts\'");
if ((value!=null)&&(value.Length!=this.FeatureCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.FeatureCount)+" was expected for variable \'ZeroFeatureValueInstanceCounts\'");
}
this.zeroFeatureValueInstanceCounts = value;
this.ZeroFeatureValueInstanceCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_Ins6_isInitialised = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised = false;
@ -326,102 +326,102 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_B = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_B = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_B[FeatureRange] = Gaussian.Uniform();
this.Weights_F[FeatureRange] = Gaussian.Uniform();
}
this.WeightPrecisionRateRates_F_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_F[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.featureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisions_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.WeightPrecisions_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_F[FeatureRange] = Gamma.Uniform();
}
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRateRates_F_reduced = GammaFromShapeAndRateOpBase.SampleAverageConditional(1.0, 1.0);
}
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
this.SharedWeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
this.SharedWeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
this.SharedWeightPrecisionRates_uses_F[FeatureRange][1] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.SharedWeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q = new Gamma[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = default(Gamma);
}
this.WeightPrecisionRates_depth0_uses_B[0] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[0] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[0][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_rpt_B_reduced = default(Gamma);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.WeightPrecisionRates_rpt_B_reduced = GaussianOpBase.PrecisionAverageConditional(0.0, 0.0);
}
this.WeightPrecisionRates_uses_B = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
this.WeightPrecisionRates_uses_B[FeatureRange][0] = Gamma.Uniform();
}
this.WeightPrecisionRates_uses_F = new Gamma[this.featureCount][];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F = new Gamma[this.FeatureCount][];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_F[FeatureRange] = new Gamma[2];
this.WeightPrecisionRates_uses_F[FeatureRange][0] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_F[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_uses_F[1] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[1] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_F[1][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_marginal_F = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_marginal_F = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_marginal_F[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_uses_B[1] = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[1] = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_uses_B[1][FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_depth0_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_depth0_B[FeatureRange] = Gamma.Uniform();
}
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B = new DistributionStructArray<Gamma,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_use_B[FeatureRange] = Gamma.Uniform();
}
this.Weights_uses_B[0] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B[0] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[0][FeatureRange] = Gaussian.Uniform();
}
this.Weights_uses_F[1] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_F[1] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_marginal_F = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[FeatureRange] = Gaussian.Uniform();
}
this.Weights_uses_B[1] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_uses_B[1] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_B[1][FeatureRange] = Gaussian.Uniform();
}
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.featureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.featureCount];
if (this.featureCount>0) {
this.WeightPrecisions_B_FeatureRange__Q = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_B = new Gamma[this.FeatureCount];
this.CommonWeightPrecision_rep_F = new Gamma[this.FeatureCount];
if (this.FeatureCount>0) {
this.Zero_reduced = 0.0;
Constrain.Equal<double>(this.Zero_reduced, 0.0);
}
@ -438,7 +438,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; 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);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange] = GammaFromShapeAndRateOp_Laplace.Q(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced);
this.SharedWeightPrecisionRates_F[FeatureRange] = GammaFromShapeAndRateOp_Laplace.SampleAverageConditional(this.SharedWeightPrecisionRates_use_B[FeatureRange], 1.0, this.WeightPrecisionRateRates_F_reduced, this.SharedWeightPrecisionRates_B_FeatureRange__Q[FeatureRange]);
this.SharedWeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 0, this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
@ -447,7 +447,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.CommonWeightPrecision_rep_B_toDef = ReplicateOp_Divide.ToDef<Gamma>(this.CommonWeightPrecision_rep_B, this.CommonWeightPrecision_rep_B_toDef);
this.CommonWeightPrecision_rep_F_marginal = ReplicateOp_Divide.Marginal<Gamma>(this.CommonWeightPrecision_rep_B_toDef, this.CommonWeightPrecision_F, this.CommonWeightPrecision_rep_F_marginal);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.CommonWeightPrecision_rep_F[FeatureRange] = ReplicateOp_Divide.UsesAverageConditional<Gamma>(this.CommonWeightPrecision_rep_B[FeatureRange], this.CommonWeightPrecision_rep_F_marginal, FeatureRange, this.CommonWeightPrecision_rep_F[FeatureRange]);
this.WeightPrecisions_F[FeatureRange] = GammaRatioOp_Laplace.RatioAverageConditional(this.WeightPrecisions_B[FeatureRange], this.CommonWeightPrecision_rep_F[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisions_B[FeatureRange] = GaussianOp.PrecisionAverageConditional(this.Weights_B[FeatureRange], Gaussian.PointMass(0.0), this.WeightPrecisions_F[FeatureRange]);
@ -457,31 +457,31 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.Weights_F, 1, this.Weights_uses_F[1]);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalIncrementArray<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.Weights_uses_B[1], this.Weights_marginal_F);
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]);
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.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]);
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.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);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightPrecisionRates_uses_F[FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_F[FeatureRange], 1, this.SharedWeightPrecisionRates_uses_F[FeatureRange][1]);
this.WeightPrecisionRates_uses_F[FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.SharedWeightPrecisionRates_uses_F[FeatureRange][1], 0, this.WeightPrecisionRates_uses_F[FeatureRange][0]);
this.WeightPrecisionRates_depth0_F[FeatureRange] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_depth0_F[FeatureRange], this.WeightPrecisionRates_uses_F[FeatureRange][0]);
}
this.WeightPrecisionRates_depth0_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_F, 1, this.WeightPrecisionRates_depth0_uses_F[1]);
this.WeightPrecisionRates_depth0_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.IndexedWeightPrecisionRates_B, this.featureIndexes, this.WeightPrecisionRates_depth0_marginal_F);
this.WeightPrecisionRates_depth0_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gamma,double>,Gamma,DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.IndexedWeightPrecisionRates_B, this.FeatureIndexes, this.WeightPrecisionRates_depth0_marginal_F);
this.WeightPrecisionRates_depth0_uses_B[1] = JaggedSubarrayWithMarginalOp<double>.ArrayAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_F[1], this.WeightPrecisionRates_depth0_marginal_F, this.WeightPrecisionRates_depth0_uses_B[1]);
this.WeightPrecisionRates_depth0_B = ReplicateOp_NoDivide.DefAverageConditional<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B, this.WeightPrecisionRates_depth0_B);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][0] = ArrayHelper.SetTo<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange][0], this.WeightPrecisionRates_depth0_B[FeatureRange]);
this.WeightPrecisionRates_use_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gamma>(this.WeightPrecisionRates_uses_B[FeatureRange], this.WeightPrecisionRates_use_B[FeatureRange]);
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = ArrayHelper.SetTo<Gamma>(this.SharedWeightPrecisionRates_uses_B[FeatureRange][1], this.WeightPrecisionRates_use_B[FeatureRange]);
@ -499,7 +499,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_11_isDone&&((!initialise)||this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_11_isInitialised)) {
return ;
}
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_marginal_F);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.FeatureIndexes, this.Weights_marginal_F);
this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_11_isDone = true;
this.Changed_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_11_isInitialised = true;
}
@ -511,7 +511,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_InstanceCount_Ins5_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_InstanceCount_Ins5_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisions_B[FeatureRange] = Gamma.Uniform();
this.SharedWeightPrecisionRates_use_B[FeatureRange] = Gamma.Uniform();
this.SharedWeightPrecisionRates_uses_B[FeatureRange][1] = Gamma.Uniform();
@ -531,7 +531,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightConstraints_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Changed_FeatureCount_WeightConstraints_isDone = true;
}
@ -541,7 +541,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone) {
return ;
}
this.WeightPrecisionRates_depth0_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B[0], this.weightPrecisionRateConstraints);
this.WeightPrecisionRates_depth0_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gamma,double>>(this.WeightPrecisionRates_depth0_uses_B[0], this.WeightPrecisionRateConstraints);
this.Changed_FeatureCount_WeightPrecisionRateConstraints_isDone = true;
}
@ -551,8 +551,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_ZeroFeatureValueInstanceCounts_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][1] = PowerPlateOp.ValueAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.zeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_uses_B[FeatureRange][1]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.WeightPrecisionRates_uses_B[FeatureRange][1] = PowerPlateOp.ValueAverageConditional<Gamma>(this.WeightPrecisionRates_rpt_B_reduced, this.ZeroFeatureValueInstanceCounts[FeatureRange], this.WeightPrecisionRates_uses_B[FeatureRange][1]);
}
this.Changed_FeatureCount_ZeroFeatureValueInstanceCounts_isDone = true;
}
@ -563,9 +563,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = GaussianOpBase.PrecisionAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], 0.0);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = GaussianOpBase.PrecisionAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], 0.0);
}
}
this.Changed_FeatureValues_InstanceCount_InstanceFeatureCounts_isDone = true;
@ -577,27 +577,27 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.IndexedWeightPrecisionRates_B = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.instanceCount);
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.IndexedWeightPrecisionRates_B = new DistributionRefArray<DistributionStructArray<Gamma,double>,double[]>(this.InstanceCount);
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Changed_InstanceCount_isDone = true;
}
@ -607,24 +607,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.IndexedWeightPrecisionRates_B[InstanceRange] = new DistributionStructArray<Gamma,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.IndexedWeightPrecisionRates_B[InstanceRange] = new DistributionStructArray<Gamma,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeightPrecisionRates_B[InstanceRange][InstanceFeatureRanges] = Gamma.Uniform();
}
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
}
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = true;
}
@ -636,8 +636,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isDone&&((!initialise)||this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount_FeatureInd10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,12 +33,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
public DistributionStructArray<Bernoulli,bool> Labels_F;
/// <summary>Message to marginal of 'Labels'</summary>
public DistributionStructArray<Bernoulli,bool> Labels_marginal_F;
@ -48,9 +48,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
private int numberOfIterationsDone;
public Gaussian[] Score_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public Gaussian[][] Weights_depth1_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
public Gaussian[] Weights_depth1_rep_B_toDef;
@ -68,11 +68,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -88,13 +88,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_FeatureValues_InstanceCount_WeightConstraints_WeightPriors_isDone = false;
}
@ -104,11 +104,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -130,10 +130,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_WeightConstraints_WeightPriors_isDone = false;
this.Changed_FeatureCount_WeightConstraints_WeightPriors_isDone = false;
@ -146,10 +146,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_WeightPriors_isDone = false;
this.Changed_FeatureCount_WeightPriors_isDone = false;
@ -169,10 +169,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.Weights_depth1_rep_F_marginal = new Gaussian[this.featureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.featureCount];
this.Weights_depth1_rep_F = new Gaussian[this.featureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.featureCount][];
this.Weights_depth1_rep_F_marginal = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_F = new Gaussian[this.FeatureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.FeatureCount][];
this.Changed_FeatureCount_isDone = true;
}
@ -182,9 +182,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_FeatureValues_InstanceCount_WeightConstraints_WeightPriors_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange]);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
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);
@ -200,17 +200,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.instanceCount];
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.InstanceCount];
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange][InstanceRange] = Gaussian.Uniform();
this.Weights_depth1_rep_F[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
}
@ -223,8 +223,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_WeightConstraints_WeightPriors_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; 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]);
}
}
@ -237,7 +237,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightConstraints_WeightPriors_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
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]);
}
this.Changed_FeatureCount_WeightConstraints_WeightPriors_isDone = true;
@ -249,7 +249,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_WeightPriors_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
this.Weights_depth1_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
}
@ -262,16 +262,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.Labels_F = new DistributionStructArray<Bernoulli,bool>(this.instanceCount);
this.NoisyScore_F = new Gaussian[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Labels_marginal_F = new DistributionStructArray<Bernoulli,bool>(this.instanceCount);
this.Labels_F = new DistributionStructArray<Bernoulli,bool>(this.InstanceCount);
this.NoisyScore_F = new Gaussian[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Labels_marginal_F = new DistributionStructArray<Bernoulli,bool>(this.InstanceCount);
this.Labels_use_B_reduced = default(Bernoulli);
if (this.instanceCount>0) {
if (this.InstanceCount>0) {
this.Labels_use_B_reduced = Bernoulli.Uniform();
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_F[InstanceRange] = Bernoulli.Uniform();
this.Score_F[InstanceRange] = Gaussian.Uniform();
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
@ -286,8 +286,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -297,8 +297,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Просмотреть файл

@ -35,15 +35,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
/// <summary>Message to marginal of 'ModelSelector'</summary>
public Bernoulli ModelSelector_marginal_F;
public Bernoulli ModelSelector_selector_B;
@ -65,9 +65,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>The constant 'vBernoulli0'</summary>
public Bernoulli vBernoulli0;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public Gaussian[][] Weights_depth1_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
public Gaussian[] Weights_depth1_rep_B_toDef;
@ -89,11 +89,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -108,13 +108,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -126,11 +126,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -145,13 +145,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -171,10 +171,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -187,10 +187,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_WeightPriors_isDone = false;
@ -209,13 +209,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.Weights_depth1_rep_F_marginal = new Gaussian[this.featureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.featureCount];
this.Weights_depth1_rep_F = new Gaussian[this.featureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.featureCount][];
this.ModelSelector_selector_cases_0_rep3_uses_B = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_F_marginal = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_F = new Gaussian[this.FeatureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep3_uses_B = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep3_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][1] = Bernoulli.Uniform();
@ -232,42 +232,42 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
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++) {
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.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.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]);
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++) {
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++) {
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_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[6] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, this.Weights_uses_F));
this.ModelSelector_selector_cases_0_uses_B[7] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[0], this.weightConstraints));
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
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[6] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, this.Weights_uses_F));
this.ModelSelector_selector_cases_0_uses_B[7] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[]>.LogEvidenceRatio<DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[0], this.WeightConstraints));
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.Weights_depth1_rep_B[FeatureRange], this.Weights_uses_F[1][FeatureRange], this.Weights_depth1_rep_F[FeatureRange]));
this.ModelSelector_selector_cases_0_rep3_B[FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep3_B[FeatureRange]);
}
this.ModelSelector_selector_cases_0_uses_B[12] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep3_B, this.ModelSelector_selector_cases_0_uses_B[12]);
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.Labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
}
this.ModelSelector_selector_cases_0_uses_B[17] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep8_B, this.ModelSelector_selector_cases_0_uses_B[17]);
this.ModelSelector_selector_cases_0_B = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_uses_B, this.ModelSelector_selector_cases_0_B);
@ -275,7 +275,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_B = CasesOp.BAverageConditional(this.ModelSelector_selector_cases_B);
this.ModelSelector_marginal_F = VariableOp.MarginalAverageConditional<Bernoulli>(this.ModelSelector_selector_B, this.vBernoulli0, this.ModelSelector_marginal_F);
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.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;
}
@ -285,24 +285,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.InstanceCount];
}
this.Changed_FeatureCount_InstanceCount_isDone = true;
}
@ -314,8 +314,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isDone&&((!initialise)||this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
@ -330,7 +330,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
this.Weights_depth1_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
}
@ -344,26 +344,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.ModelSelector_selector_cases_0_rep8_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep8_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_isDone = true;
@ -375,8 +375,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -386,12 +386,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Просмотреть файл

@ -35,15 +35,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
public Gaussian[] NoisyScore_F;
/// <summary>Message from use of 'NoisyScore'</summary>
public Gaussian[] NoisyScore_use_B;
@ -52,9 +52,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public Gaussian[] Score_B;
public Gaussian[] Score_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public Gaussian[][] Weights_depth1_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
public Gaussian[] Weights_depth1_rep_B_toDef;
@ -76,11 +76,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -95,13 +95,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -113,11 +113,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_FeatureCount_InstanceCount_isDone = false;
@ -132,13 +132,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -158,10 +158,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised = false;
@ -174,10 +174,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised = false;
this.Changed_WeightPriors_isDone = false;
@ -196,10 +196,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.Weights_depth1_rep_F_marginal = new Gaussian[this.featureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.featureCount];
this.Weights_depth1_rep_F = new Gaussian[this.featureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.featureCount][];
this.Weights_depth1_rep_F_marginal = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_B_toDef = new Gaussian[this.FeatureCount];
this.Weights_depth1_rep_F = new Gaussian[this.FeatureCount][];
this.Weights_depth1_rep_B = new Gaussian[this.FeatureCount][];
this.Changed_FeatureCount_isDone = true;
}
@ -211,34 +211,34 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
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++) {
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.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.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]);
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++) {
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++) {
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.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;
}
@ -248,24 +248,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange] = new Gaussian[this.InstanceCount];
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][FeatureRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.instanceCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange] = new Gaussian[this.InstanceCount];
}
this.Changed_FeatureCount_InstanceCount_isDone = true;
}
@ -277,8 +277,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isDone&&((!initialise)||this.Changed_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_WeightConst7_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_B[FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
@ -293,7 +293,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isDone&&((!initialise)||this.Changed_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_InstanceCount_Label4_isInitialised)) {
return ;
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_depth1_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
this.Weights_depth1_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[1][FeatureRange]);
}
@ -307,24 +307,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Changed_InstanceCount_isDone = true;
}
@ -334,8 +334,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -345,11 +345,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Просмотреть файл

@ -43,17 +43,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Changed_InstanceCount has executed. Set this to false to force re-execution of Changed_InstanceCount</summary>
public bool Changed_InstanceCount_isDone;
/// <summary>Field backing the ClassCount property</summary>
private int classCount;
private int ClassCount_field;
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
public Discrete Labels_F_reduced;
public Discrete[] Labels_InstanceRange__selector_B;
public DistributionStructArray<Bernoulli,bool>[] Labels_InstanceRange__selector_cases_B;
@ -103,9 +103,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[][] vbool72_reduced;
public Gaussian[][][] vdouble710_B;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightConstraints;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightPriors;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_F;
public Gaussian[][][] Weights_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
@ -124,11 +124,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int ClassCount
{
get {
return this.classCount;
return this.ClassCount_field;
}
set {
if (this.classCount!=value) {
this.classCount = value;
if (this.ClassCount_field!=value) {
this.ClassCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isDone = false;
@ -149,11 +149,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_isDone = false;
@ -172,13 +172,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_WeightC10_isInitialised = false;
@ -191,11 +191,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
@ -220,10 +220,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_WeightC10_isInitialised = false;
@ -238,10 +238,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_WeightC10_isInitialised = false;
@ -261,13 +261,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_isDone) {
return ;
}
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_rep_B_toDef = new Gaussian[this.classCount][];
this.Weights_uses_F = new Gaussian[this.classCount][][];
this.Weights_uses_B = new Gaussian[this.classCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.classCount][];
this.Weights_rep_F = new Gaussian[this.classCount][][];
this.Weights_rep_B = new Gaussian[this.classCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.ClassCount][];
this.Weights_rep_B_toDef = new Gaussian[this.ClassCount][];
this.Weights_rep_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_B = new Gaussian[this.ClassCount][][];
this.Changed_ClassCount_isDone = true;
}
@ -278,28 +278,28 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
this.SharedWeightsFirst_B_reduced = default(Gaussian);
if (this.classCount>0) {
if (this.featureCount>0) {
if (this.ClassCount>0) {
if (this.FeatureCount>0) {
this.SharedWeightsFirst_B_reduced = Gaussian.Uniform();
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_uses_F[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_uses_B[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_uses_B[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_B[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.FeatureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.FeatureCount][];
}
this.Changed_ClassCount_FeatureCount_isDone = true;
}
@ -312,25 +312,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -342,54 +342,54 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassMaxNoisyScore][7] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore]));
for(int _a7 = 0; _a7<this.classCount; _a7++) {
for(int _a7 = 0; _a7<this.ClassCount; _a7++) {
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore][_a7] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore][_a7], this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore][_a7]);
}
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassMaxNoisyScore][11] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore], this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassMaxNoisyScore][11]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Labels_InstanceRange__selector_cases_B[InstanceRange][ClassRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange], this.Labels_InstanceRange__selector_cases_B[InstanceRange][ClassRange]);
}
this.Labels_InstanceRange__selector_uses_B[InstanceRange][0] = IntCasesOp.IAverageConditional(this.Labels_InstanceRange__selector_cases_B[InstanceRange], this.Labels_InstanceRange__selector_uses_B[InstanceRange][0]);
this.Labels_InstanceRange__selector_uses_F[InstanceRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Discrete>(this.Labels_InstanceRange__selector_uses_B[InstanceRange], this.Labels_uses_F[InstanceRange][1], 1, this.Labels_InstanceRange__selector_uses_F[InstanceRange][1]);
this.Labels_InstanceRange__selector_rep_F_marginal[InstanceRange] = ReplicateOp_Divide.Marginal<Discrete>(this.Labels_InstanceRange__selector_rep_B_toDef[InstanceRange], this.Labels_InstanceRange__selector_uses_F[InstanceRange][1], this.Labels_InstanceRange__selector_rep_F_marginal[InstanceRange]);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
if (this.classCount>0) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
if (this.ClassCount>0) {
this.NoisyScores__B_reduced[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores__B_reduced[InstanceRange][ClassRange], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassRange]);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.NoisyScores__B[InstanceRange][ClassRange][ClassMaxNoisyScore] = this.NoisyScores__B_reduced[InstanceRange][ClassRange];
}
this.Labels_InstanceRange__selector_rep_F[InstanceRange][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Discrete>(this.Labels_InstanceRange__selector_rep_B_reduced, this.Labels_InstanceRange__selector_rep_F_marginal[InstanceRange], ClassRange, this.Labels_InstanceRange__selector_rep_F[InstanceRange][ClassRange]);
this.NoisyScores_use_B[InstanceRange][ClassRange] = GateEnterOp<double>.ValueAverageConditional<Gaussian>(this.NoisyScores__B[InstanceRange][ClassRange], this.Labels_InstanceRange__selector_rep_F[InstanceRange][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange], this.NoisyScores_use_B[InstanceRange][ClassRange]);
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[ClassRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange]);
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
}
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Discrete>(this.Labels_InstanceRange__selector_uses_B[InstanceRange], this.Labels_InstanceRange__selector_B[InstanceRange]);
this.Labels_uses_B[InstanceRange][1] = ArrayHelper.SetTo<Discrete>(this.Labels_uses_B[InstanceRange][1], this.Labels_InstanceRange__selector_B[InstanceRange]);
this.Labels_use_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Discrete>(this.Labels_uses_B[InstanceRange], this.Labels_use_B[InstanceRange]);
@ -404,33 +404,33 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
this.Changed_ClassCount_FeatureCount_InstanceCount_isDone = true;
@ -443,9 +443,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_WeightC10_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_WeightC10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
}
}
@ -461,8 +461,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_WeightC6_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_WeightC6_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
@ -477,9 +477,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.weightConstraints[ClassRange][_iv]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.WeightConstraints[ClassRange][_iv]);
}
}
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = true;
@ -491,8 +491,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_WeightPriors_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
}
@ -505,9 +505,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightPriors_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.SharedWeightsFirst_B_reduced, this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.SharedWeightsFirst_B_reduced, this.Weights_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_WeightPriors_isDone = true;
@ -519,56 +519,56 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_isDone) {
return ;
}
if (this.instanceCount>0) {
this.Labels_F_reduced = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
if (this.InstanceCount>0) {
this.Labels_F_reduced = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
}
this.Labels_InstanceRange__selector_rep_B_reduced = default(Discrete);
if (this.instanceCount>0) {
if (this.classCount>0) {
this.Labels_InstanceRange__selector_rep_B_reduced = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
if (this.InstanceCount>0) {
if (this.ClassCount>0) {
this.Labels_InstanceRange__selector_rep_B_reduced = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Labels_uses_F[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_uses_F[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
}
if (this.instanceCount>0) {
this.vbool72_reduced = new bool[this.classCount][];
this.Labels_InstanceRange__selector_cases_rep8_B_reduced = new Bernoulli[this.classCount][];
if (this.InstanceCount>0) {
this.vbool72_reduced = new bool[this.ClassCount][];
this.Labels_InstanceRange__selector_cases_rep8_B_reduced = new Bernoulli[this.ClassCount][];
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.instanceCount>0) {
this.Labels_InstanceRange__selector_cases_rep8_B_reduced[ClassMaxNoisyScore] = new Bernoulli[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.InstanceCount>0) {
this.Labels_InstanceRange__selector_cases_rep8_B_reduced[ClassMaxNoisyScore] = new Bernoulli[this.ClassCount];
}
for(int _a8 = 0; _a8<this.classCount; _a8++) {
if (this.instanceCount>0) {
for(int _a8 = 0; _a8<this.ClassCount; _a8++) {
if (this.InstanceCount>0) {
this.Labels_InstanceRange__selector_cases_rep8_B_reduced[ClassMaxNoisyScore][_a8] = Bernoulli.Uniform();
}
}
if (this.instanceCount>0) {
this.vbool72_reduced[ClassMaxNoisyScore] = new bool[this.classCount];
if (this.InstanceCount>0) {
this.vbool72_reduced[ClassMaxNoisyScore] = new bool[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.instanceCount>0) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.InstanceCount>0) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vbool72_reduced[ClassMaxNoisyScore][ClassRange] = true;
this.Labels_InstanceRange__selector_cases_rep8_B_reduced[ClassMaxNoisyScore][ClassRange] = Bernoulli.FromLogOdds(ConstrainEqualOp<bool>.LogEvidenceRatio(true, this.vbool72_reduced[ClassMaxNoisyScore][ClassRange]));
@ -576,9 +576,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange] = new Bernoulli[this.classCount][];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange] = new Bernoulli[this.ClassCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange] = new Bernoulli[13];
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange][10] = Bernoulli.Uniform();
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange][9] = Bernoulli.Uniform();
@ -594,99 +594,113 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange][11] = Bernoulli.Uniform();
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassRange][12] = Bernoulli.Uniform();
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassMaxNoisyScore][12] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.Labels_InstanceRange__selector_cases_rep8_B_reduced[ClassMaxNoisyScore], this.Labels_InstanceRange__selector_cases_uses_B[InstanceRange][ClassMaxNoisyScore][12]);
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.vdouble710_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.vdouble710_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.vdouble710_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.vdouble710_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble710_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange] = new Bernoulli[this.classCount][][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore] = new Bernoulli[this.classCount][];
for(int _a7 = 0; _a7<this.classCount; _a7++) {
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange] = new Bernoulli[this.ClassCount][][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore] = new Bernoulli[this.ClassCount][];
for(int _a7 = 0; _a7<this.ClassCount; _a7++) {
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore][_a7] = new Bernoulli[2];
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore][_a7][1] = Bernoulli.Uniform();
this.Labels_InstanceRange__selector_cases_rep7_uses_B[InstanceRange][ClassMaxNoisyScore][_a7][0] = Bernoulli.Uniform();
}
}
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange] = new Bernoulli[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore] = new Bernoulli[this.classCount];
for(int _a7 = 0; _a7<this.classCount; _a7++) {
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange] = new Bernoulli[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore] = new Bernoulli[this.ClassCount];
for(int _a7 = 0; _a7<this.ClassCount; _a7++) {
this.Labels_InstanceRange__selector_cases_rep7_B[InstanceRange][ClassMaxNoisyScore][_a7] = Bernoulli.Uniform();
}
}
this.Labels_InstanceRange__selector_cases_B[InstanceRange] = new DistributionStructArray<Bernoulli,bool>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Labels_InstanceRange__selector_cases_B[InstanceRange] = new DistributionStructArray<Bernoulli,bool>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Labels_InstanceRange__selector_cases_B[InstanceRange][ClassRange] = Bernoulli.Uniform();
}
this.Labels_InstanceRange__selector_uses_B[InstanceRange][0] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_InstanceRange__selector_uses_F[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_InstanceRange__selector_uses_B[InstanceRange][0] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_InstanceRange__selector_uses_B[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_InstanceRange__selector_uses_F[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_InstanceRange__selector_rep_F_marginal[InstanceRange] = ReplicateOp_Divide.MarginalInit<Discrete>(this.Labels_InstanceRange__selector_uses_F[InstanceRange][1]);
this.Labels_InstanceRange__selector_rep_B_toDef[InstanceRange] = ReplicateOp_Divide.ToDefInit<Discrete>(this.Labels_InstanceRange__selector_uses_F[InstanceRange][1]);
this.Labels_InstanceRange__selector_rep_F[InstanceRange] = new Discrete[this.classCount];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Labels_InstanceRange__selector_rep_F[InstanceRange][ClassRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_InstanceRange__selector_rep_F[InstanceRange] = new Discrete[this.ClassCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Labels_InstanceRange__selector_rep_F[InstanceRange][ClassRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
}
this.NoisyScores__B_reduced[InstanceRange] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores__B_reduced[InstanceRange] = new Gaussian[this.ClassCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores__B_reduced[InstanceRange][ClassRange] = default(Gaussian);
if (this.classCount>0) {
if (this.ClassCount>0) {
this.NoisyScores__B_reduced[InstanceRange][ClassRange] = Gaussian.Uniform();
}
}
this.NoisyScores__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores__B[InstanceRange][ClassRange] = new Gaussian[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.NoisyScores__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores__B[InstanceRange][ClassRange] = new Gaussian[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.NoisyScores__B[InstanceRange][ClassRange][ClassMaxNoisyScore] = this.NoisyScores__B_reduced[InstanceRange][ClassRange];
}
}
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores_use_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.Labels_marginal_F[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_use_B[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_uses_B[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_uses_B[InstanceRange][0] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_InstanceRange__selector_uses_B[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_InstanceRange__selector_B[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.classCount));
this.Labels_marginal_F[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_use_B[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_uses_B[InstanceRange][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_uses_B[InstanceRange][0] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
this.Labels_InstanceRange__selector_B[InstanceRange] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.ClassCount));
}
this.Changed_ClassCount_InstanceCount_isDone = true;
}
@ -698,28 +712,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble710_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble710_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isDone = true;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_WeightC11_isInitialised = true;
@ -732,48 +735,48 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
this.Labels_F_reduced = default(Discrete);
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.instanceCount][];
this.Labels_uses_F = new Discrete[this.instanceCount][];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.InstanceCount][];
this.Labels_uses_F = new Discrete[this.InstanceCount][];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_uses_F[InstanceRange] = new Discrete[2];
}
this.Labels_InstanceRange__selector_cases_uses_B = new Bernoulli[this.instanceCount][][];
this.Labels_InstanceRange__selector_cases_uses_B = new Bernoulli[this.InstanceCount][][];
this.vbool72_reduced = default(bool[][]);
this.Labels_InstanceRange__selector_cases_rep8_B_reduced = default(Bernoulli[][]);
this.NoisyScoreDeltas_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.instanceCount][][];
this.vdouble710_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_F = new Gaussian[this.instanceCount][][];
this.Labels_InstanceRange__selector_cases_rep7_uses_B = new Bernoulli[this.instanceCount][][][];
this.Labels_InstanceRange__selector_cases_rep7_B = new Bernoulli[this.instanceCount][][];
this.Labels_InstanceRange__selector_cases_B = new DistributionStructArray<Bernoulli,bool>[this.instanceCount];
this.Labels_InstanceRange__selector_uses_B = new Discrete[this.instanceCount][];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScoreDeltas_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.InstanceCount][][];
this.vdouble710_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_F = new Gaussian[this.InstanceCount][][];
this.Labels_InstanceRange__selector_cases_rep7_uses_B = new Bernoulli[this.InstanceCount][][][];
this.Labels_InstanceRange__selector_cases_rep7_B = new Bernoulli[this.InstanceCount][][];
this.Labels_InstanceRange__selector_cases_B = new DistributionStructArray<Bernoulli,bool>[this.InstanceCount];
this.Labels_InstanceRange__selector_uses_B = new Discrete[this.InstanceCount][];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_uses_B[InstanceRange] = new Discrete[2];
}
this.Labels_InstanceRange__selector_uses_F = new Discrete[this.instanceCount][];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_uses_F = new Discrete[this.InstanceCount][];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_uses_F[InstanceRange] = new Discrete[2];
}
this.Labels_InstanceRange__selector_rep_F_marginal = new Discrete[this.instanceCount];
this.Labels_InstanceRange__selector_rep_B_toDef = new Discrete[this.instanceCount];
this.Labels_InstanceRange__selector_rep_F = new Discrete[this.instanceCount][];
this.NoisyScores__B_reduced = new Gaussian[this.instanceCount][];
this.NoisyScores__B = new Gaussian[this.instanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Labels_marginal_F = new DistributionRefArray<Discrete,int>(this.instanceCount);
this.Labels_use_B = new DistributionRefArray<Discrete,int>(this.instanceCount);
this.Labels_uses_B = new Discrete[this.instanceCount][];
this.Labels_InstanceRange__selector_B = new Discrete[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Labels_InstanceRange__selector_rep_F_marginal = new Discrete[this.InstanceCount];
this.Labels_InstanceRange__selector_rep_B_toDef = new Discrete[this.InstanceCount];
this.Labels_InstanceRange__selector_rep_F = new Discrete[this.InstanceCount][];
this.NoisyScores__B_reduced = new Gaussian[this.InstanceCount][];
this.NoisyScores__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Labels_marginal_F = new DistributionRefArray<Discrete,int>(this.InstanceCount);
this.Labels_uses_B = new Discrete[this.InstanceCount][];
this.Labels_InstanceRange__selector_B = new Discrete[this.InstanceCount];
this.Labels_use_B = new DistributionRefArray<Discrete,int>(this.InstanceCount);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_uses_B[InstanceRange] = new Discrete[2];
}
this.Changed_InstanceCount_isDone = true;

Просмотреть файл

@ -67,19 +67,19 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Changed_InstanceCount_Labels has executed. Set this to false to force re-execution of Changed_InstanceCount_Labels</summary>
public bool Changed_InstanceCount_Labels_isDone;
/// <summary>Field backing the ClassCount property</summary>
private int classCount;
private int ClassCount_field;
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private int[] labels;
private int[] Labels_field;
public Gaussian[][][] MaxNoisyScore_0__B;
public Gaussian[][][] MaxNoisyScore_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
@ -136,9 +136,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[][][] vbool39;
public Gaussian[][][] vdouble379_B;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightConstraints;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightPriors;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_depth0_F;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_F;
/// <summary>Message to marginal of 'Weights'</summary>
@ -162,11 +162,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int ClassCount
{
get {
return this.classCount;
return this.ClassCount_field;
}
set {
if (this.classCount!=value) {
this.classCount = value;
if (this.ClassCount_field!=value) {
this.ClassCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
@ -192,11 +192,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isInitialised = false;
@ -220,13 +220,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isInitialised = false;
@ -245,11 +245,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_InstanceCount_Labels_isDone = false;
@ -274,13 +274,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
@ -309,10 +309,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isInitialised = false;
@ -332,10 +332,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isInitialised = false;
@ -359,29 +359,29 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_isDone) {
return ;
}
this.ModelSelector_selector_cases_0_rep4_rep_uses_B = new Bernoulli[this.classCount][][];
this.ModelSelector_selector_cases_0_rep4_rep_B = new Bernoulli[this.classCount][];
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.classCount];
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_F = new Gaussian[this.classCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_B = new Gaussian[this.classCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.classCount][];
this.Weights_rep_B_toDef = new Gaussian[this.classCount][];
this.Weights_rep_F = new Gaussian[this.classCount][][];
this.Weights_rep_B = new Gaussian[this.classCount][][];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep4_rep_uses_B = new Bernoulli[this.ClassCount][][];
this.ModelSelector_selector_cases_0_rep4_rep_B = new Bernoulli[this.ClassCount][];
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.ClassCount];
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.ClassCount][];
this.Weights_rep_B_toDef = new Gaussian[this.ClassCount][];
this.Weights_rep_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_B = new Gaussian[this.ClassCount][][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep4_B[ClassRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep10_rep_uses_B = new Bernoulli[this.classCount][][];
this.ModelSelector_selector_cases_0_rep10_rep_B = new Bernoulli[this.classCount][];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.classCount];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep10_rep_uses_B = new Bernoulli[this.ClassCount][][];
this.ModelSelector_selector_cases_0_rep10_rep_B = new Bernoulli[this.ClassCount][];
this.ModelSelector_selector_cases_0_rep10_B = new Bernoulli[this.ClassCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep10_B[ClassRange] = Bernoulli.Uniform();
}
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Changed_ClassCount_isDone = true;
}
@ -391,56 +391,54 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_uses_B[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_B[ClassRange][_iv][0] = Gaussian.Uniform();
this.Weights_uses_B[ClassRange][_iv][1] = Gaussian.Uniform();
}
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.featureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange] = new Bernoulli[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange] = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.FeatureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange] = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange] = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][2] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange][FeatureRange] = Bernoulli.Uniform();
}
this.Weights_depth0_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_depth0_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth0_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange] = new Bernoulli[this.featureCount][];
this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange] = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange] = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange] = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange][FeatureRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange][FeatureRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange][FeatureRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange][FeatureRange] = Bernoulli.Uniform();
}
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_marginal_F[ClassRange][_iv] = Gaussian.Uniform();
}
}
@ -455,32 +453,32 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -489,16 +487,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -511,14 +509,14 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[ClassRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange]);
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_uses_B[ClassRange][FeatureRange][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange][1], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_use_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange]);
@ -526,41 +524,41 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][0] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 0, this.Weights_uses_F[ClassRange][FeatureRange][0]);
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][0] = Bernoulli.FromLogOdds(SequentialCopyOp.LogEvidenceRatio<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_use_B[ClassRange][FeatureRange]));
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][0] = Bernoulli.FromLogOdds(SequentialCopyOp.LogEvidenceRatio<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_use_B[ClassRange][FeatureRange]));
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][2] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange]));
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange], this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange][FeatureRange]);
}
this.ModelSelector_selector_cases_0_rep4_B[ClassRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange], this.ModelSelector_selector_cases_0_rep4_B[ClassRange]);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth0_F[ClassRange][_iv] = ArrayHelper.SetTo<Gaussian>(this.Weights_depth0_F[ClassRange][_iv], this.Weights_uses_F[ClassRange][_iv][0]);
}
}
this.ModelSelector_selector_cases_0_uses_B[10] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep4_B, this.ModelSelector_selector_cases_0_uses_B[10]);
this.ModelSelector_selector_cases_0_uses_B[16] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[][]>.LogEvidenceRatio<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.Weights_depth0_F, this.weightConstraints));
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_uses_B[16] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp<double[][]>.LogEvidenceRatio<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.Weights_depth0_F, this.WeightConstraints));
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange][FeatureRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F[ClassRange][FeatureRange]));
this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_rep_uses_B[ClassRange][FeatureRange], this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange][FeatureRange]);
}
this.ModelSelector_selector_cases_0_rep10_B[ClassRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_rep_B[ClassRange], this.ModelSelector_selector_cases_0_rep10_B[ClassRange]);
}
this.ModelSelector_selector_cases_0_uses_B[22] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep10_B, this.ModelSelector_selector_cases_0_uses_B[22]);
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.ModelSelector_selector_cases_0_rep20_uses_B[InstanceRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore]));
}
}
this.ModelSelector_selector_cases_0_rep20_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep20_uses_B[InstanceRange], this.ModelSelector_selector_cases_0_rep20_B[InstanceRange]);
}
this.ModelSelector_selector_cases_0_uses_B[32] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep20_B, this.ModelSelector_selector_cases_0_uses_B[32]);
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange][ClassRange][0] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(true, this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]));
}
@ -571,7 +569,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep24_B[InstanceRange] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep24_rep_B[InstanceRange], this.ModelSelector_selector_cases_0_rep24_B[InstanceRange]);
}
this.ModelSelector_selector_cases_0_uses_B[36] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep24_B, this.ModelSelector_selector_cases_0_uses_B[36]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep28_B[FeatureRange] = Bernoulli.FromLogOdds(FastSumOp.LogEvidenceRatio(0.0, this.TransposedWeights_F[FeatureRange]));
}
this.ModelSelector_selector_cases_0_uses_B[41] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep28_B, this.ModelSelector_selector_cases_0_uses_B[41]);
@ -579,8 +577,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
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.vBernoulli2, this.ModelSelector_marginal_F);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
@ -593,15 +591,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -621,10 +619,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
@ -640,17 +638,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
}
}
@ -665,9 +663,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
@ -685,9 +683,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
}
@ -703,24 +701,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
@ -736,8 +730,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
@ -753,18 +747,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone = true;
@ -777,9 +771,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.weightConstraints[ClassRange][_iv]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.WeightConstraints[ClassRange][_iv]);
}
}
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = true;
@ -791,26 +785,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange] = new Bernoulli[this.classCount][];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange] = new Bernoulli[this.ClassCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange][ClassRange] = new Bernoulli[2];
}
this.ModelSelector_selector_cases_0_rep24_rep_B[InstanceRange] = new Bernoulli[this.classCount];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep24_rep_B[InstanceRange] = new Bernoulli[this.ClassCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange][ClassRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep24_rep_B[InstanceRange][ClassRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep25_rep_B[InstanceRange] = new Bernoulli[this.classCount];
this.ModelSelector_selector_cases_0_rep25_rep_B[InstanceRange] = new Bernoulli[this.ClassCount];
}
this.Changed_ClassCount_InstanceCount_isDone = true;
}
@ -821,67 +815,85 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.vdouble379_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.vdouble379_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
@ -889,25 +901,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.ModelSelector_selector_cases_0_rep13_B[InstanceRange] = Bernoulli.FromLogOdds(DiscreteUniform.LogEvidenceRatio(this.labels[InstanceRange], this.classCount));
this.ModelSelector_selector_cases_0_rep13_B[InstanceRange] = Bernoulli.FromLogOdds(DiscreteUniform.LogEvidenceRatio(this.Labels[InstanceRange], this.ClassCount));
}
this.ModelSelector_selector_cases_0_uses_B[25] = ReplicateOp_NoDivide.DefAverageConditional<Bernoulli>(this.ModelSelector_selector_cases_0_rep13_B, this.ModelSelector_selector_cases_0_uses_B[25]);
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep24_rep_uses_B[InstanceRange][ClassRange][0] = Bernoulli.Uniform();
}
this.vbool39[InstanceRange] = new bool[this.classCount][];
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.vbool39[InstanceRange] = new bool[this.ClassCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep25_rep_B[InstanceRange][ClassRange] = Bernoulli.Uniform();
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool39[InstanceRange][ClassMaxNoisyScore] = new bool[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool39[InstanceRange][ClassMaxNoisyScore] = new bool[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vbool39[InstanceRange][ClassMaxNoisyScore][ClassRange] = true;
this.ModelSelector_selector_cases_0_rep25_rep_B[InstanceRange][ClassRange] = Bernoulli.FromLogOdds(ConstrainEqualOp<bool>.LogEvidenceRatio(true, this.vbool39[InstanceRange][ClassMaxNoisyScore][ClassRange]));
@ -928,47 +940,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_14_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
@ -988,8 +971,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_12_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
@ -1004,25 +987,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.ModelSelector_selector_cases_0_rep28_B = new Bernoulli[this.featureCount];
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.ModelSelector_selector_cases_0_rep28_B = new Bernoulli[this.FeatureCount];
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep28_B[FeatureRange] = Bernoulli.Uniform();
}
this.TransposedWeightSums_reduced = default(double);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.TransposedWeightSums_reduced = 0.0;
}
this.ModelSelector_selector_cases_0_rep29_B_reduced = default(Bernoulli);
if (this.featureCount>0) {
if (this.FeatureCount>0) {
this.ModelSelector_selector_cases_0_rep29_B_reduced = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep29_B = new Bernoulli[this.featureCount];
if (this.featureCount>0) {
this.ModelSelector_selector_cases_0_rep29_B = new Bernoulli[this.FeatureCount];
if (this.FeatureCount>0) {
this.ModelSelector_selector_cases_0_rep29_B_reduced = Bernoulli.FromLogOdds(ConstrainEqualOp<double>.LogEvidenceRatio(this.TransposedWeightSums_reduced, 0.0));
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep29_B[FeatureRange] = this.ModelSelector_selector_cases_0_rep29_B_reduced;
this.ModelSelector_selector_cases_0_rep29_B[FeatureRange] = this.ModelSelector_selector_cases_0_rep29_B_reduced;
}
@ -1036,43 +1019,43 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_0__B = new Gaussian[this.instanceCount][][];
this.vdouble379_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.instanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.instanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.instanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.ModelSelector_selector_cases_0_rep13_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.InstanceCount][][];
this.vdouble379_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep13_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep13_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep20_uses_B = new Bernoulli[this.instanceCount][];
this.ModelSelector_selector_cases_0_rep20_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep20_uses_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep20_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep20_uses_B[InstanceRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep20_uses_B[InstanceRange][0] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep20_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep24_rep_uses_B = new Bernoulli[this.instanceCount][][];
this.ModelSelector_selector_cases_0_rep24_rep_B = new Bernoulli[this.instanceCount][];
this.ModelSelector_selector_cases_0_rep24_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep24_rep_uses_B = new Bernoulli[this.InstanceCount][][];
this.ModelSelector_selector_cases_0_rep24_B = new Bernoulli[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep24_rep_B = new Bernoulli[this.InstanceCount][];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep24_B[InstanceRange] = Bernoulli.Uniform();
}
this.vbool39 = new bool[this.instanceCount][][];
this.ModelSelector_selector_cases_0_rep25_B = new Bernoulli[this.instanceCount];
this.ModelSelector_selector_cases_0_rep25_rep_B = new Bernoulli[this.instanceCount][];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.vbool39 = new bool[this.InstanceCount][][];
this.ModelSelector_selector_cases_0_rep25_B = new Bernoulli[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep25_rep_B = new Bernoulli[this.InstanceCount][];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep25_B[InstanceRange] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_isDone = true;
@ -1084,7 +1067,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_Labels_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep20_uses_B[InstanceRange][1] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_Labels_isDone = true;

Просмотреть файл

@ -65,19 +65,19 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Changed_InstanceCount has executed. Set this to false to force re-execution of Changed_InstanceCount</summary>
public bool Changed_InstanceCount_isDone;
/// <summary>Field backing the ClassCount property</summary>
private int classCount;
private int ClassCount_field;
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the Labels property</summary>
private int[] labels;
private int[] Labels_field;
public Gaussian[][][] MaxNoisyScore_0__B;
public Gaussian[][][] MaxNoisyScore_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
@ -104,9 +104,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[][][] vbool8;
public Gaussian[][][] vdouble48_B;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightConstraints;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightPriors;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_F;
/// <summary>Message to marginal of 'Weights'</summary>
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_marginal_F;
@ -129,11 +129,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int ClassCount
{
get {
return this.classCount;
return this.ClassCount_field;
}
set {
if (this.classCount!=value) {
this.classCount = value;
if (this.ClassCount_field!=value) {
this.ClassCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
@ -159,11 +159,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised = false;
@ -187,13 +187,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised = false;
@ -212,11 +212,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
@ -240,13 +240,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised = false;
@ -274,10 +274,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised = false;
@ -297,10 +297,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised = false;
@ -324,16 +324,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_isDone) {
return ;
}
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_F = new Gaussian[this.classCount][][];
this.Weights_uses_B = new Gaussian[this.classCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.classCount][];
this.Weights_rep_B_toDef = new Gaussian[this.classCount][];
this.Weights_rep_F = new Gaussian[this.classCount][][];
this.Weights_rep_B = new Gaussian[this.classCount][][];
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_rep_F_marginal = new Gaussian[this.ClassCount][];
this.Weights_rep_B_toDef = new Gaussian[this.ClassCount][];
this.Weights_rep_F = new Gaussian[this.ClassCount][][];
this.Weights_rep_B = new Gaussian[this.ClassCount][][];
this.Changed_ClassCount_isDone = true;
}
@ -343,34 +343,34 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_marginal_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_uses_F[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
}
this.Weights_uses_B[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_B[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_uses_B[ClassRange][_iv][0] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.featureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.featureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.featureCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_rep_F_marginal[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_B_toDef[ClassRange] = new Gaussian[this.FeatureCount];
this.Weights_rep_F[ClassRange] = new Gaussian[this.FeatureCount][];
this.Weights_rep_B[ClassRange] = new Gaussian[this.FeatureCount][];
}
this.Changed_ClassCount_FeatureCount_isDone = true;
}
@ -383,32 +383,32 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -417,16 +417,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -439,14 +439,14 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange], this.FeatureValues[InstanceRange][FeatureRange]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalIncrement<Gaussian>(this.Weights_rep_F_marginal[ClassRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange]);
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDef<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_uses_B[ClassRange][FeatureRange][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange][1], this.Weights_rep_B_toDef[ClassRange][FeatureRange]);
this.Weights_use_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange]);
@ -454,8 +454,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
@ -468,15 +468,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -496,10 +496,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
@ -515,23 +515,23 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_B[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.instanceCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_B[ClassRange][FeatureRange] = new Gaussian[this.InstanceCount];
}
}
this.Changed_ClassCount_FeatureCount_InstanceCount_isDone = true;
@ -544,9 +544,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = Gaussian.Uniform();
this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange] = Gaussian.Uniform();
@ -564,9 +564,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
}
@ -582,16 +582,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
@ -609,8 +609,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.Marginal<Gaussian>(this.Weights_rep_B_toDef[ClassRange][FeatureRange], this.Weights_uses_F[ClassRange][FeatureRange][1], this.Weights_rep_F_marginal[ClassRange][FeatureRange]);
}
@ -626,18 +626,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone = true;
@ -650,9 +650,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.weightConstraints[ClassRange][_iv]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.WeightConstraints[ClassRange][_iv]);
}
}
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = true;
@ -664,16 +664,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
}
this.Changed_ClassCount_InstanceCount_isDone = true;
}
@ -684,67 +684,85 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.vdouble48_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.vdouble48_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
@ -752,15 +770,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.vbool8[InstanceRange] = new bool[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool8[InstanceRange][ClassMaxNoisyScore] = new bool[this.classCount];
this.vbool8[InstanceRange] = new bool[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool8[InstanceRange][ClassMaxNoisyScore] = new bool[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vbool8[InstanceRange][ClassMaxNoisyScore][ClassRange] = true;
Constrain.Equal<bool>(true, this.vbool8[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -779,36 +797,25 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
}
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_12_isInitialised = true;
@ -821,8 +828,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureValues_Labels_10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
@ -837,9 +844,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
if (this.featureCount>0) {
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
if (this.FeatureCount>0) {
this.TransposedWeightSums_reduced = 0.0;
Constrain.Equal<double>(this.TransposedWeightSums_reduced, 0.0);
}
@ -852,23 +859,23 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.instanceCount][][];
this.vdouble48_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.instanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.instanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.instanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.vbool8 = new bool[this.instanceCount][][];
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.InstanceCount][][];
this.vdouble48_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.vbool8 = new bool[this.InstanceCount][][];
this.Changed_InstanceCount_isDone = true;
}

Просмотреть файл

@ -27,17 +27,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionStructArray<Gaussian,double>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
public DistributionStructArray<Bernoulli,bool> Labels_F;
/// <summary>Message to marginal of 'Labels'</summary>
public DistributionStructArray<Bernoulli,bool> Labels_marginal_F;
@ -47,9 +47,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
private int numberOfIterationsDone;
public Gaussian[] Score_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_FeatureIndexes_F;
/// <summary>Message to marginal of 'Weights'</summary>
public DistributionStructArray<Gaussian,double> Weights_marginal_F;
@ -64,11 +64,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
}
}
@ -78,13 +78,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPriors_isDone = false;
this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPri6_isDone = false;
@ -95,13 +95,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPri6_isDone = false;
}
@ -111,11 +111,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -129,13 +129,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPriors_isDone = false;
@ -155,10 +155,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_WeightConstraints_WeightPriors_isDone = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPriors_isDone = false;
@ -170,10 +170,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_WeightPriors_isDone = false;
this.Changed_WeightConstraints_WeightPriors_isDone = false;
@ -191,9 +191,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
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]);
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);
@ -209,9 +209,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_marginal_F);
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]);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.FeatureIndexes, this.Weights_marginal_F);
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]);
}
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_WeightConstraints_WeightPriors_isDone = true;
}
@ -222,18 +222,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.Labels_F = new DistributionStructArray<Bernoulli,bool>(this.instanceCount);
this.NoisyScore_F = new Gaussian[this.instanceCount];
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
this.Score_F = new Gaussian[this.instanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Labels_marginal_F = new DistributionStructArray<Bernoulli,bool>(this.instanceCount);
this.Labels_F = new DistributionStructArray<Bernoulli,bool>(this.InstanceCount);
this.NoisyScore_F = new Gaussian[this.InstanceCount];
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
this.Score_F = new Gaussian[this.InstanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Labels_marginal_F = new DistributionStructArray<Bernoulli,bool>(this.InstanceCount);
this.Labels_use_B_reduced = default(Bernoulli);
if (this.instanceCount>0) {
if (this.InstanceCount>0) {
this.Labels_use_B_reduced = Bernoulli.Uniform();
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Labels_F[InstanceRange] = Bernoulli.Uniform();
this.Score_F[InstanceRange] = Gaussian.Uniform();
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
@ -248,17 +248,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}
@ -271,8 +271,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -282,9 +282,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Просмотреть файл

@ -33,20 +33,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionStructArray<Gaussian,double>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
/// <summary>Message to marginal of 'ModelSelector'</summary>
public Bernoulli ModelSelector_marginal_F;
public Bernoulli ModelSelector_selector_B;
@ -65,9 +65,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>The constant 'vBernoulli1'</summary>
public Bernoulli vBernoulli1;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public DistributionStructArray<Gaussian,double> Weights_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_FeatureIndexes_F;
/// <summary>Message to marginal of 'Weights'</summary>
@ -83,11 +83,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
}
}
@ -97,13 +97,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone = false;
@ -115,13 +115,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = false;
@ -133,11 +133,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -152,13 +152,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isDone = false;
@ -171,13 +171,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = false;
@ -197,10 +197,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_WeightConstraints_WeightPriors_isDone = false;
@ -213,10 +213,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_WeightPriors_isDone = false;
@ -237,30 +237,30 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
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]);
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.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]);
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.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_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>(this.IndexedWeights_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.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>(this.IndexedWeights_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);
@ -278,7 +278,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone&&((!initialise)||this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised)) {
return ;
}
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_marginal_F);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.FeatureIndexes, this.Weights_marginal_F);
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone = true;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = true;
}
@ -289,28 +289,28 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.ModelSelector_selector_cases_0_rep9_B = new Bernoulli[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep9_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep9_B[InstanceRange] = Bernoulli.Uniform();
}
this.Changed_InstanceCount_isDone = true;
@ -322,20 +322,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
}
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = true;
}
@ -347,8 +347,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isDone&&((!initialise)||this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}
@ -362,8 +362,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -373,12 +373,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Просмотреть файл

@ -33,20 +33,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionStructArray<Gaussian,double>[] FeatureScores_B;
public DistributionStructArray<Gaussian,double>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionStructArray<Gaussian,double>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
/// <summary>Field backing the Labels property</summary>
private bool[] labels;
private bool[] Labels_field;
public Gaussian[] NoisyScore_F;
/// <summary>Message from use of 'NoisyScore'</summary>
public Gaussian[] NoisyScore_use_B;
@ -55,9 +55,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public Gaussian[] Score_B;
public Gaussian[] Score_F;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionStructArray<Gaussian,double> weightConstraints;
private DistributionStructArray<Gaussian,double> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionStructArray<Gaussian,double> weightPriors;
private DistributionStructArray<Gaussian,double> WeightPriors_field;
public DistributionStructArray<Gaussian,double> Weights_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_FeatureIndexes_F;
/// <summary>Message to marginal of 'Weights'</summary>
@ -73,11 +73,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
}
}
@ -87,13 +87,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone = false;
@ -105,13 +105,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = false;
@ -123,11 +123,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -142,13 +142,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isDone = false;
@ -161,13 +161,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = false;
@ -187,10 +187,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_WeightConstraints_WeightPriors_isDone = false;
@ -203,10 +203,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionStructArray<Gaussian,double> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised = false;
this.Changed_WeightPriors_isDone = false;
@ -227,20 +227,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
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]);
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.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]);
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.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));
}
@ -256,7 +256,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone&&((!initialise)||this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised)) {
return ;
}
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.featureIndexes, this.Weights_marginal_F);
this.Weights_marginal_F = JaggedSubarrayWithMarginalOp<double>.MarginalAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_uses_F[1], this.IndexedWeights_B, this.FeatureIndexes, this.Weights_marginal_F);
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isDone = true;
this.Changed_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_WeightConstra6_isInitialised = true;
}
@ -267,26 +267,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Score_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
this.FeatureScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Score_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_F = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_F = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_F[InstanceRange] = Gaussian.Uniform();
}
this.NoisyScore_use_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.NoisyScore_use_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.NoisyScore_use_B[InstanceRange] = Gaussian.Uniform();
}
this.Score_B = new Gaussian[this.instanceCount];
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Score_B = new Gaussian[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Score_B[InstanceRange] = Gaussian.Uniform();
}
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.IndexedWeights_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Changed_InstanceCount_isDone = true;
}
@ -296,20 +296,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.Weights_FeatureIndexes_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.IndexedWeights_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
}
this.Changed_InstanceCount_InstanceFeatureCounts_isDone = true;
}
@ -321,8 +321,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isDone&&((!initialise)||this.Changed_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureV5_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}
@ -336,8 +336,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightConstraints_WeightPriors_isDone) {
return ;
}
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.weightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.weightPriors, 1, this.Weights_uses_F[1]);
this.Weights_uses_B[0] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B[0], this.WeightConstraints);
this.Weights_uses_F[1] = ReplicateOp_NoDivide.UsesAverageConditional<DistributionStructArray<Gaussian,double>>(this.Weights_uses_B, this.WeightPriors, 1, this.Weights_uses_F[1]);
this.Changed_WeightConstraints_WeightPriors_isDone = true;
}
@ -347,11 +347,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_WeightPriors_isDone) {
return ;
}
this.Weights_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.weightPriors);
this.Weights_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_B[0] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_uses_F[1] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Weights_marginal_F = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.WeightPriors);
this.Changed_WeightPriors_isDone = true;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -43,24 +43,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>True if Changed_InstanceCount has executed. Set this to false to force re-execution of Changed_InstanceCount</summary>
public bool Changed_InstanceCount_isDone;
/// <summary>Field backing the ClassCount property</summary>
private int classCount;
private int ClassCount_field;
/// <summary>True if Constant has executed. Set this to false to force re-execution of Constant</summary>
public bool Constant_isDone;
/// <summary>Field backing the FeatureCount property</summary>
private int featureCount;
private int FeatureCount_field;
/// <summary>Field backing the FeatureIndexes property</summary>
private int[][] featureIndexes;
private int[][] FeatureIndexes_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] FeatureScores_F;
/// <summary>Field backing the FeatureValues property</summary>
private double[][] featureValues;
private double[][] FeatureValues_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[] IndexedWeights_B;
/// <summary>Field backing the InstanceCount property</summary>
private int instanceCount;
private int InstanceCount_field;
/// <summary>Field backing the InstanceFeatureCounts property</summary>
private int[] instanceFeatureCounts;
private int[] InstanceFeatureCounts_field;
/// <summary>Field backing the Labels property</summary>
private int[] labels;
private int[] Labels_field;
public Gaussian[][][] MaxNoisyScore_0__B;
public Gaussian[][][] MaxNoisyScore_rep_B;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
@ -87,9 +87,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public bool[][][] vbool12;
public Gaussian[][][] vdouble87_B;
/// <summary>Field backing the WeightConstraints property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightConstraints;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints_field;
/// <summary>Field backing the WeightPriors property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> weightPriors;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors_field;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_depth1_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> Weights_depth1_F;
/// <summary>Buffer for JaggedSubarrayOp&lt;double&gt;.ItemsAverageConditional&lt;DistributionStructArray&lt;Gaussian, double&gt;, Gaussian, DistributionStructArray&lt;Gaussian, double&gt;&gt;</summary>
@ -112,11 +112,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int ClassCount
{
get {
return this.classCount;
return this.ClassCount_field;
}
set {
if (this.classCount!=value) {
this.classCount = value;
if (this.ClassCount_field!=value) {
this.ClassCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
@ -136,11 +136,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int FeatureCount
{
get {
return this.featureCount;
return this.FeatureCount_field;
}
set {
if (this.featureCount!=value) {
this.featureCount = value;
if (this.FeatureCount_field!=value) {
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
@ -157,13 +157,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[][] FeatureIndexes
{
get {
return this.featureIndexes;
return this.FeatureIndexes_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureIndexes\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureIndexes\'");
}
this.featureIndexes = value;
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
@ -176,13 +176,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public double[][] FeatureValues
{
get {
return this.featureValues;
return this.FeatureValues_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'FeatureValues\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'FeatureValues\'");
}
this.featureValues = value;
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
@ -195,11 +195,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int InstanceCount
{
get {
return this.instanceCount;
return this.InstanceCount_field;
}
set {
if (this.instanceCount!=value) {
this.instanceCount = value;
if (this.InstanceCount_field!=value) {
this.InstanceCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
@ -217,13 +217,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] InstanceFeatureCounts
{
get {
return this.instanceFeatureCounts;
return this.InstanceFeatureCounts_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'InstanceFeatureCounts\'");
}
this.instanceFeatureCounts = value;
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
@ -237,13 +237,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public int[] Labels
{
get {
return this.labels;
return this.Labels_field;
}
set {
if ((value!=null)&&(value.Length!=this.instanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.instanceCount)+" was expected for variable \'Labels\'");
if ((value!=null)&&(value.Length!=this.InstanceCount)) {
throw new ArgumentException(((("Provided array of length "+value.Length)+" when length ")+this.InstanceCount)+" was expected for variable \'Labels\'");
}
this.labels = value;
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = false;
@ -265,10 +265,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightConstraints
{
get {
return this.weightConstraints;
return this.WeightConstraints_field;
}
set {
this.weightConstraints = value;
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
@ -282,10 +282,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> WeightPriors
{
get {
return this.weightPriors;
return this.WeightPriors_field;
}
set {
this.weightPriors = value;
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
@ -303,17 +303,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_isDone) {
return ;
}
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_uses_F = new Gaussian[this.classCount][][];
this.Weights_uses_B = new Gaussian[this.classCount][][];
this.Weights_depth1_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Weights_depth1_F_ClassRange__marginal = new DistributionStructArray<Gaussian,double>[this.classCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.classCount];
this.Weights_FeatureIndexes_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.classCount];
this.Weights_depth1_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_marginal_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_depth1_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_depth1_F_ClassRange__marginal = new DistributionStructArray<Gaussian,double>[this.ClassCount];
this.Weights_FeatureIndexes_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.ClassCount];
this.Weights_FeatureIndexes_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.ClassCount];
this.Weights_depth1_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Changed_ClassCount_isDone = true;
}
@ -323,53 +323,53 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_marginal_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
this.Weights_uses_F[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
this.Weights_uses_B[ClassRange] = new Gaussian[this.featureCount][];
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_B[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_uses_B[ClassRange][_iv][0] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
this.Weights_depth1_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_depth1_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.featureCount);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_depth1_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_B[ClassRange][_iv] = Gaussian.Uniform();
}
}
@ -384,42 +384,42 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.weightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = ArrayHelper.SetTo<Gaussian>(this.Weights_depth1_F[ClassRange][_iv], this.Weights_uses_F[ClassRange][_iv][1]);
}
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F[ClassRange], this.Weights_FeatureIndexes_B[ClassRange], this.featureIndexes, this.Weights_depth1_F_ClassRange__marginal[ClassRange]);
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F[ClassRange], this.Weights_FeatureIndexes_B[ClassRange], this.FeatureIndexes, this.Weights_depth1_F_ClassRange__marginal[ClassRange]);
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = JaggedSubarrayOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.IndexedWeights_B[InstanceRange][ClassRange], this.Weights_depth1_F[ClassRange], this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.featureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[ClassRange][InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges]);
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = JaggedSubarrayOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.IndexedWeights_B[InstanceRange][ClassRange], this.Weights_depth1_F[ClassRange], this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.FeatureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[ClassRange][InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
@ -431,15 +431,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -449,26 +449,26 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_B[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScores_use_B[InstanceRange][ClassRange], 1.0);
this.FeatureScores_B[InstanceRange][ClassRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(this.Scores_B[InstanceRange][ClassRange], this.Scores_F[InstanceRange][ClassRange], this.FeatureScores_F[InstanceRange][ClassRange], this.FeatureScores_B[InstanceRange][ClassRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][InstanceFeatureRanges], this.featureValues[InstanceRange][InstanceFeatureRanges]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][ClassRange][InstanceFeatureRanges], this.FeatureValues[InstanceRange][InstanceFeatureRanges]);
}
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.MarginalIncrement<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange], this.IndexedWeights_B[InstanceRange][ClassRange], this.featureIndexes, InstanceRange);
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.MarginalIncrement<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange], this.IndexedWeights_B[InstanceRange][ClassRange], this.FeatureIndexes, InstanceRange);
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange] = ArrayHelper.SetTo<DistributionStructArray<Gaussian,double>>(this.Weights_FeatureIndexes_B[ClassRange][InstanceRange], this.IndexedWeights_B[InstanceRange][ClassRange]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_depth1_B[ClassRange] = JaggedSubarrayOp<double>.ArrayAverageConditional<Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_FeatureIndexes_B[ClassRange], this.featureIndexes, this.Weights_depth1_B[ClassRange]);
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_depth1_B[ClassRange] = JaggedSubarrayOp<double>.ArrayAverageConditional<Gaussian,DistributionStructArray<Gaussian,double>>(this.Weights_FeatureIndexes_B[ClassRange], this.FeatureIndexes, this.Weights_depth1_B[ClassRange]);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][1] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][1], this.Weights_depth1_B[ClassRange][_iv]);
}
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_use_B[ClassRange][FeatureRange] = ReplicateOp_NoDivide.DefAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange]);
}
}
this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.featureCount; FeatureRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
@ -482,8 +482,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.Weights_depth1_F[ClassRange]);
@ -498,9 +498,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int _iv = 0; _iv<this.featureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.weightConstraints[ClassRange][_iv]);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_B[ClassRange][_iv][0] = ArrayHelper.SetTo<Gaussian>(this.Weights_uses_B[ClassRange][_iv][0], this.WeightConstraints[ClassRange][_iv]);
}
}
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = true;
@ -512,29 +512,29 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_isDone) {
return ;
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.IndexedWeights_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.classCount);
this.FeatureScores_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.IndexedWeights_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_FeatureIndexes_B[ClassRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.instanceCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_B[ClassRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.InstanceCount);
}
this.Changed_ClassCount_InstanceCount_isDone = true;
}
@ -545,22 +545,22 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeights_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.instanceFeatureCounts[InstanceRange]);
this.IndexedWeights_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
}
}
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = true;
@ -573,9 +573,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.IndexedWeights_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
@ -591,97 +591,115 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.vdouble87_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.vdouble87_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.classCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.classCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.classCount];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
@ -689,15 +707,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.vbool12[InstanceRange] = new bool[this.classCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool12[InstanceRange][ClassMaxNoisyScore] = new bool[this.classCount];
this.vbool12[InstanceRange] = new bool[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vbool12[InstanceRange][ClassMaxNoisyScore] = new bool[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vbool12[InstanceRange][ClassMaxNoisyScore][ClassRange] = true;
Constrain.Equal<bool>(true, this.vbool12[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -716,32 +734,19 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.instanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.classCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.classCount; ClassMaxNoisyScore++) {
if (this.labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
}
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = true;
@ -753,9 +758,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_FeatureCount_isDone) {
return ;
}
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.featureCount);
if (this.featureCount>0) {
this.TransposedWeights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
this.TransposedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.FeatureCount);
if (this.FeatureCount>0) {
this.TransposedWeightSums_reduced = 0.0;
Constrain.Equal<double>(this.TransposedWeightSums_reduced, 0.0);
}
@ -768,24 +773,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Changed_InstanceCount_isDone) {
return ;
}
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.instanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.instanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.instanceCount][][];
this.vdouble87_B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.instanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.instanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.instanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.instanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.instanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.IndexedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.instanceCount];
this.vbool12 = new bool[this.instanceCount][][];
this.FeatureScores_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.Scores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.NoisyScores_F = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.MaxNoisyScore_rep_F_marginal = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_B_toDef = new Gaussian[this.InstanceCount][];
this.MaxNoisyScore_rep_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_F = new Gaussian[this.InstanceCount][][];
this.NoisyScoreDeltas_B = new Gaussian[this.InstanceCount][][];
this.vdouble87_B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_0__B = new Gaussian[this.InstanceCount][][];
this.MaxNoisyScore_rep_B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount][];
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B = new Gaussian[this.InstanceCount][][];
this.NoisyScores_use_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.Scores_B = new DistributionStructArray<Gaussian,double>[this.InstanceCount];
this.FeatureScores_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.IndexedWeights_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>[this.InstanceCount];
this.vbool12 = new bool[this.InstanceCount][][];
this.Changed_InstanceCount_isDone = true;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
{
#region Fields
/// <summary>Field backing the AffinityNoiseVariance property</summary>
private double affinityNoiseVariance;
private double AffinityNoiseVariance_field;
/// <summary>True if Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27 has executed. Set this to false to force re-execution of Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27</summary>
public bool Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27_isDone;
/// <summary>True if Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User29 has executed. Set this to false to force re-execution of Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User29</summary>
@ -83,11 +83,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionStructArray<Gaussian,double> ItemBias_use_F_marginal;
public Gaussian[] itemBiasObs_B;
/// <summary>Field backing the ItemBiasPrior property</summary>
private DistributionStructArray<Gaussian,double> itemBiasPrior;
private DistributionStructArray<Gaussian,double> ItemBiasPrior_field;
/// <summary>Field backing the ItemCount property</summary>
private int itemCount;
private int ItemCount_field;
/// <summary>Field backing the ItemIds property</summary>
private IReadOnlyList<int> itemIds;
private IReadOnlyList<int> ItemIds_field;
public DistributionStructArray<Gaussian,double>[] itemTrait_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> ItemTraits_itemItemIds_observation__F;
/// <summary>Message from use of 'ItemTraits'</summary>
@ -95,12 +95,12 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
/// <summary>Buffer for GetItemsOp&lt;double[]&gt;.ItemsAverageConditional&lt;DistributionRefArray&lt;DistributionStructArray&lt;Gaussian, double&gt;, double[]&gt;, DistributionStructArray&lt;Gaussian, double&gt;&gt;</summary>
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> ItemTraits_use_F_marginal;
/// <summary>Field backing the ItemTraitsPrior property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> itemTraitsPrior;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> ItemTraitsPrior_field;
public int[] NextRating_reduced;
/// <summary>Field backing the NumberOfIterationsDone property</summary>
private int numberOfIterationsDone;
/// <summary>Field backing the ObservationCount property</summary>
private int observationCount;
private int ObservationCount_field;
public Discrete Ratings_F_reduced;
/// <summary>Message to marginal of 'Ratings'</summary>
public DistributionRefArray<Discrete,int> Ratings_marginal_F;
@ -112,7 +112,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Discrete&gt;</summary>
public Discrete[] Ratings_observation__selector_uses_B_toDef;
/// <summary>Field backing the TraitCount property</summary>
private int traitCount;
private int TraitCount_field;
/// <summary>Buffer for IsBetweenGaussianOp.LogEvidenceRatio</summary>
public double[][] true_logZ;
public DistributionStructArray<Gaussian,double> UserBias_itemUserIds_observation__F;
@ -122,15 +122,15 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionStructArray<Gaussian,double> UserBias_use_F_marginal;
public Gaussian[] userBiasObs_B;
/// <summary>Field backing the UserBiasPrior property</summary>
private DistributionStructArray<Gaussian,double> userBiasPrior;
private DistributionStructArray<Gaussian,double> UserBiasPrior_field;
/// <summary>Field backing the UserCount property</summary>
private int userCount;
private int UserCount_field;
/// <summary>Field backing the UserIds property</summary>
private IReadOnlyList<int> userIds;
private IReadOnlyList<int> UserIds_field;
/// <summary>Field backing the UserThresholdCount property</summary>
private int userThresholdCount;
private int UserThresholdCount_field;
/// <summary>Field backing the UserThresholdNoiseVariance property</summary>
private double userThresholdNoiseVariance;
private double UserThresholdNoiseVariance_field;
public DistributionStructArray<Gaussian,double>[] UserThresholds_0__gi_0__F;
/// <summary>Buffer for ReplicateOp_Divide.Marginal&lt;Gaussian&gt;</summary>
public Gaussian[] UserThresholds_depth2_rep_B_toDef;
@ -146,7 +146,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public Gaussian UserThresholdsObs_B_reduced;
public DistributionStructArray<Gaussian,double>[] UserThresholdsObs_F;
/// <summary>Field backing the UserThresholdsPrior property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> userThresholdsPrior;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserThresholdsPrior_field;
public DistributionStructArray<Gaussian,double>[] userTrait_B;
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserTraits_itemUserIds_observation__F;
/// <summary>Message from use of 'UserTraits'</summary>
@ -154,9 +154,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
/// <summary>Buffer for GetItemsOp&lt;double[]&gt;.ItemsAverageConditional&lt;DistributionRefArray&lt;DistributionStructArray&lt;Gaussian, double&gt;, double[]&gt;, DistributionStructArray&lt;Gaussian, double&gt;&gt;</summary>
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserTraits_use_F_marginal;
/// <summary>Field backing the UserTraitsPrior property</summary>
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> userTraitsPrior;
private DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserTraitsPrior_field;
/// <summary>Field backing the UseSharedUserThresholds property</summary>
private bool useSharedUserThresholds;
private bool UseSharedUserThresholds_field;
public bool vbool9_reduced;
public DistributionStructArray<Gaussian,double>[] vdouble__78_F;
public DistributionStructArray<Gaussian,double>[] vdouble__88_F;
@ -176,11 +176,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public double AffinityNoiseVariance
{
get {
return this.affinityNoiseVariance;
return this.AffinityNoiseVariance_field;
}
set {
if (this.affinityNoiseVariance!=value) {
this.affinityNoiseVariance = value;
if (this.AffinityNoiseVariance_field!=value) {
this.AffinityNoiseVariance_field = value;
this.numberOfIterationsDone = 0;
this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27_isDone = false;
this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User29_isDone = false;
@ -192,10 +192,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionStructArray<Gaussian,double> ItemBiasPrior
{
get {
return this.itemBiasPrior;
return this.ItemBiasPrior_field;
}
set {
this.itemBiasPrior = value;
this.ItemBiasPrior_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ItemBiasPrior_isDone = false;
this.Changed_ItemBiasPrior_ItemIds_ObservationCount_isDone = false;
@ -210,11 +210,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public int ItemCount
{
get {
return this.itemCount;
return this.ItemCount_field;
}
set {
if (this.itemCount!=value) {
this.itemCount = value;
if (this.ItemCount_field!=value) {
this.ItemCount_field = value;
this.numberOfIterationsDone = 0;
}
}
@ -224,13 +224,13 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public IReadOnlyList<int> ItemIds
{
get {
return this.itemIds;
return this.ItemIds_field;
}
set {
if ((value!=null)&&(value.Count!=this.observationCount)) {
throw new ArgumentException(((("Provided array of length "+value.Count)+" when length ")+this.observationCount)+" was expected for variable \'ItemIds\'");
if ((value!=null)&&(value.Count!=this.ObservationCount)) {
throw new ArgumentException(((("Provided array of length "+value.Count)+" when length ")+this.ObservationCount)+" was expected for variable \'ItemIds\'");
}
this.itemIds = value;
this.ItemIds_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_isDone = false;
this.Changed_ItemBiasPrior_ItemIds_ObservationCount_isDone = false;
@ -247,10 +247,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> ItemTraitsPrior
{
get {
return this.itemTraitsPrior;
return this.ItemTraitsPrior_field;
}
set {
this.itemTraitsPrior = value;
this.ItemTraitsPrior_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_isDone = false;
this.Changed_ItemTraitsPrior_isDone = false;
@ -274,11 +274,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public int ObservationCount
{
get {
return this.observationCount;
return this.ObservationCount_field;
}
set {
if (this.observationCount!=value) {
this.observationCount = value;
if (this.ObservationCount_field!=value) {
this.ObservationCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ObservationCount_UseSharedUserThresholds_isDone = false;
this.Changed_ObservationCount_isDone = false;
@ -307,11 +307,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public int TraitCount
{
get {
return this.traitCount;
return this.TraitCount_field;
}
set {
if (this.traitCount!=value) {
this.traitCount = value;
if (this.TraitCount_field!=value) {
this.TraitCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ObservationCount_TraitCount_isDone = false;
this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_isDone = false;
@ -328,10 +328,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionStructArray<Gaussian,double> UserBiasPrior
{
get {
return this.userBiasPrior;
return this.UserBiasPrior_field;
}
set {
this.userBiasPrior = value;
this.UserBiasPrior_field = value;
this.numberOfIterationsDone = 0;
this.Changed_UserBiasPrior_isDone = false;
this.Changed_ObservationCount_UserBiasPrior_UserIds_isDone = false;
@ -346,11 +346,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public int UserCount
{
get {
return this.userCount;
return this.UserCount_field;
}
set {
if (this.userCount!=value) {
this.userCount = value;
if (this.UserCount_field!=value) {
this.UserCount_field = value;
this.numberOfIterationsDone = 0;
}
}
@ -360,13 +360,13 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public IReadOnlyList<int> UserIds
{
get {
return this.userIds;
return this.UserIds_field;
}
set {
if ((value!=null)&&(value.Count!=this.observationCount)) {
throw new ArgumentException(((("Provided array of length "+value.Count)+" when length ")+this.observationCount)+" was expected for variable \'UserIds\'");
if ((value!=null)&&(value.Count!=this.ObservationCount)) {
throw new ArgumentException(((("Provided array of length "+value.Count)+" when length ")+this.ObservationCount)+" was expected for variable \'UserIds\'");
}
this.userIds = value;
this.UserIds_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ObservationCount_UserIds_UserTraitsPrior_isDone = false;
this.Changed_ObservationCount_UserBiasPrior_UserIds_isDone = false;
@ -385,11 +385,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public int UserThresholdCount
{
get {
return this.userThresholdCount;
return this.UserThresholdCount_field;
}
set {
if (this.userThresholdCount!=value) {
this.userThresholdCount = value;
if (this.UserThresholdCount_field!=value) {
this.UserThresholdCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_UserThresholdCount_UseSharedUserThresholds_isDone = false;
this.Changed_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone = false;
@ -408,11 +408,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public double UserThresholdNoiseVariance
{
get {
return this.userThresholdNoiseVariance;
return this.UserThresholdNoiseVariance_field;
}
set {
if (this.userThresholdNoiseVariance!=value) {
this.userThresholdNoiseVariance = value;
if (this.UserThresholdNoiseVariance_field!=value) {
this.UserThresholdNoiseVariance_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ObservationCount_UserIds_UserThresholdCount_UserThresholdNoiseVariance_UserThresholdsPrior_U28_isDone = false;
this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User29_isDone = false;
@ -424,10 +424,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserThresholdsPrior
{
get {
return this.userThresholdsPrior;
return this.UserThresholdsPrior_field;
}
set {
this.userThresholdsPrior = value;
this.UserThresholdsPrior_field = value;
this.numberOfIterationsDone = 0;
this.Changed_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone = false;
this.Changed_UserThresholdsPrior_isDone = false;
@ -443,10 +443,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]> UserTraitsPrior
{
get {
return this.userTraitsPrior;
return this.UserTraitsPrior_field;
}
set {
this.userTraitsPrior = value;
this.UserTraitsPrior_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ObservationCount_UserIds_UserTraitsPrior_isDone = false;
this.Changed_UserTraitsPrior_isDone = false;
@ -462,11 +462,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
public bool UseSharedUserThresholds
{
get {
return this.useSharedUserThresholds;
return this.UseSharedUserThresholds_field;
}
set {
if (this.useSharedUserThresholds!=value) {
this.useSharedUserThresholds = value;
if (this.UseSharedUserThresholds_field!=value) {
this.UseSharedUserThresholds_field = value;
this.numberOfIterationsDone = 0;
this.Changed_UseSharedUserThresholds_isDone = false;
this.Changed_UserThresholdCount_UseSharedUserThresholds_isDone = false;
@ -491,8 +491,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.vdouble169_F[observation] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.vdouble168_F[observation], this.affinityNoiseVariance);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.vdouble169_F[observation] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.vdouble168_F[observation], this.AffinityNoiseVariance);
}
this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User27_isDone = true;
}
@ -503,7 +503,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_AffinityNoiseVariance_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_User29_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
for(int ratingValue = 0; ratingValue<this.vint45; ratingValue++) {
this.true_logZ[observation][ratingValue] = IsBetweenGaussianOp.LogZ(Bernoulli.PointMass(true), this.vdouble169_F[observation], this.vdouble__89_F[observation][this.CurrentRating_reduced[ratingValue]], this.vdouble__89_F[observation][this.NextRating_reduced[ratingValue]]);
this.Ratings_observation__selector_cases_uses_B[observation][ratingValue][6] = Bernoulli.FromLogOdds(IsBetweenGaussianOp.LogEvidenceRatio(true, this.vdouble169_F[observation], this.vdouble__89_F[observation][this.CurrentRating_reduced[ratingValue]], this.vdouble__89_F[observation][this.NextRating_reduced[ratingValue]], this.true_logZ[observation][ratingValue]));
@ -522,9 +522,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemBiasPrior_isDone) {
return ;
}
this.ItemBias_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.itemBiasPrior);
this.ItemBias_use_F_marginal = GetItemsOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.itemBiasPrior);
this.ItemBias_use_F_marginal = GetItemsOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.itemBiasPrior, this.ItemBias_use_B, this.ItemBias_use_F_marginal);
this.ItemBias_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.ItemBiasPrior);
this.ItemBias_use_F_marginal = GetItemsOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.ItemBiasPrior);
this.ItemBias_use_F_marginal = GetItemsOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.ItemBiasPrior, this.ItemBias_use_B, this.ItemBias_use_F_marginal);
this.Changed_ItemBiasPrior_isDone = true;
}
@ -534,7 +534,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_UserBiasPrior_UserIds_User26_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.vdouble168_F[observation] = DoublePlusOp.SumAverageConditional(this.vdouble166_F[observation], this.vdouble167_F[observation]);
}
this.Changed_ItemBiasPrior_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_UserBiasPrior_UserIds_User26_isDone = true;
@ -546,8 +546,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemBiasPrior_ItemIds_ObservationCount_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.ItemBias_itemItemIds_observation__F[observation] = GetItemsOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian>(this.itemBiasObs_B[observation], this.itemBiasPrior, this.ItemBias_use_F_marginal, this.itemIds, observation, this.ItemBias_itemItemIds_observation__F[observation]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.ItemBias_itemItemIds_observation__F[observation] = GetItemsOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian>(this.itemBiasObs_B[observation], this.ItemBiasPrior, this.ItemBias_use_F_marginal, this.ItemIds, observation, this.ItemBias_itemItemIds_observation__F[observation]);
this.vdouble165_F[observation] = GaussianProductOp_SHG09.ProductAverageConditional(this.ItemBias_itemItemIds_observation__F[observation], 1.0, this.itemBiasObs_B[observation]);
}
this.Changed_ItemBiasPrior_ItemIds_ObservationCount_isDone = true;
@ -559,7 +559,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemBiasPrior_ItemIds_ObservationCount_UserBiasPrior_UserIds_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.vdouble166_F[observation] = DoublePlusOp.SumAverageConditional(this.vdouble163_F[observation], this.vdouble165_F[observation]);
}
this.Changed_ItemBiasPrior_ItemIds_ObservationCount_UserBiasPrior_UserIds_isDone = true;
@ -571,8 +571,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.ItemTraits_itemItemIds_observation__F[observation] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.itemTraitsPrior[this.itemIds[observation]]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.ItemTraits_itemItemIds_observation__F[observation] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.ItemTraitsPrior[this.ItemIds[observation]]);
}
this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_isDone = true;
}
@ -583,8 +583,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.ItemTraits_itemItemIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.itemTrait_B[observation], this.itemTraitsPrior, this.ItemTraits_use_F_marginal, this.itemIds, observation, this.ItemTraits_itemItemIds_observation__F[observation]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.ItemTraits_itemItemIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.itemTrait_B[observation], this.ItemTraitsPrior, this.ItemTraits_use_F_marginal, this.ItemIds, observation, this.ItemTraits_itemItemIds_observation__F[observation]);
}
this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_isDone = true;
}
@ -595,8 +595,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemIds_ItemTraitsPrior_ObservationCount_TraitCount_UserIds_UserTraitsPrior_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int trait = 0; trait<this.traitCount; trait++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
for(int trait = 0; trait<this.TraitCount; trait++) {
this.vdouble__78_F[observation][trait] = GaussianProductOp_SHG09.ProductAverageConditional(this.UserTraits_itemUserIds_observation__F[observation][trait], this.ItemTraits_itemItemIds_observation__F[observation][trait], this.userTrait_B[observation][trait], this.itemTrait_B[observation][trait]);
}
this.vdouble167_F[observation] = FastSumOp.SumAverageConditional(this.vdouble__78_F[observation]);
@ -610,9 +610,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ItemTraitsPrior_isDone) {
return ;
}
this.ItemTraits_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.itemTraitsPrior);
this.ItemTraits_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.itemTraitsPrior);
this.ItemTraits_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.itemTraitsPrior, this.ItemTraits_use_B, this.ItemTraits_use_F_marginal);
this.ItemTraits_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.ItemTraitsPrior);
this.ItemTraits_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.ItemTraitsPrior);
this.ItemTraits_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.ItemTraitsPrior, this.ItemTraits_use_B, this.ItemTraits_use_F_marginal);
this.Changed_ItemTraitsPrior_isDone = true;
}
@ -623,34 +623,34 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
return ;
}
this.Ratings_F_reduced = default(Discrete);
this.Ratings_marginal_F = new DistributionRefArray<Discrete,int>(this.observationCount);
this.vdouble__78_F = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.vdouble166_F = new Gaussian[this.observationCount];
this.vdouble165_F = new Gaussian[this.observationCount];
this.ItemBias_itemItemIds_observation__F = new DistributionStructArray<Gaussian,double>(this.observationCount);
this.itemBiasObs_B = new Gaussian[this.observationCount];
this.vdouble163_F = new Gaussian[this.observationCount];
this.UserBias_itemUserIds_observation__F = new DistributionStructArray<Gaussian,double>(this.observationCount);
this.userBiasObs_B = new Gaussian[this.observationCount];
this.itemTrait_B = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.Ratings_observation__selector_uses_B = new Discrete[this.observationCount][];
this.vdouble__88_F = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.Ratings_observation__selector_cases_uses_B = new Bernoulli[this.observationCount][][];
this.vdouble__89_F = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.ItemTraits_itemItemIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.observationCount);
this.true_logZ = new double[this.observationCount][];
this.vdouble169_F = new Gaussian[this.observationCount];
this.userTrait_B = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.vdouble168_F = new Gaussian[this.observationCount];
this.vdouble167_F = new Gaussian[this.observationCount];
this.UserTraits_itemUserIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.observationCount);
this.UserThresholdsObs_F = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.Ratings_observation__selector_cases_B = new DistributionStructArray<Bernoulli,bool>[this.observationCount];
this.UserThresholdsObs_B = new DistributionStructArray<Gaussian,double>[this.observationCount];
this.Ratings_marginal_F = new DistributionRefArray<Discrete,int>(this.ObservationCount);
this.vdouble__78_F = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.vdouble166_F = new Gaussian[this.ObservationCount];
this.vdouble165_F = new Gaussian[this.ObservationCount];
this.ItemBias_itemItemIds_observation__F = new DistributionStructArray<Gaussian,double>(this.ObservationCount);
this.itemBiasObs_B = new Gaussian[this.ObservationCount];
this.vdouble163_F = new Gaussian[this.ObservationCount];
this.UserBias_itemUserIds_observation__F = new DistributionStructArray<Gaussian,double>(this.ObservationCount);
this.userBiasObs_B = new Gaussian[this.ObservationCount];
this.itemTrait_B = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.Ratings_observation__selector_uses_B = new Discrete[this.ObservationCount][];
this.vdouble__88_F = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.Ratings_observation__selector_cases_uses_B = new Bernoulli[this.ObservationCount][][];
this.vdouble__89_F = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.ItemTraits_itemItemIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ObservationCount);
this.true_logZ = new double[this.ObservationCount][];
this.vdouble169_F = new Gaussian[this.ObservationCount];
this.userTrait_B = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.vdouble168_F = new Gaussian[this.ObservationCount];
this.vdouble167_F = new Gaussian[this.ObservationCount];
this.UserTraits_itemUserIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ObservationCount);
this.UserThresholdsObs_F = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.Ratings_observation__selector_cases_B = new DistributionStructArray<Bernoulli,bool>[this.ObservationCount];
this.UserThresholdsObs_B = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
this.CurrentRating_reduced = default(int[]);
this.NextRating_reduced = default(int[]);
this.Ratings_observation__selector_uses_B_toDef = new Discrete[this.observationCount];
for(int observation = 0; observation<this.observationCount; observation++) {
this.Ratings_observation__selector_uses_B_toDef = new Discrete[this.ObservationCount];
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.Ratings_observation__selector_uses_B[observation] = new Discrete[3];
this.vdouble169_F[observation] = Gaussian.Uniform();
this.vdouble168_F[observation] = Gaussian.Uniform();
@ -672,14 +672,14 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_TraitCount_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.vdouble__78_F[observation] = new DistributionStructArray<Gaussian,double>(this.traitCount);
this.userTrait_B[observation] = new DistributionStructArray<Gaussian,double>(this.traitCount);
for(int trait = 0; trait<this.traitCount; trait++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.vdouble__78_F[observation] = new DistributionStructArray<Gaussian,double>(this.TraitCount);
this.userTrait_B[observation] = new DistributionStructArray<Gaussian,double>(this.TraitCount);
for(int trait = 0; trait<this.TraitCount; trait++) {
this.userTrait_B[observation][trait] = Gaussian.Uniform();
}
this.itemTrait_B[observation] = new DistributionStructArray<Gaussian,double>(this.traitCount);
for(int trait = 0; trait<this.traitCount; trait++) {
this.itemTrait_B[observation] = new DistributionStructArray<Gaussian,double>(this.TraitCount);
for(int trait = 0; trait<this.TraitCount; trait++) {
this.itemTrait_B[observation][trait] = Gaussian.Uniform();
this.vdouble__78_F[observation][trait] = Gaussian.Uniform();
}
@ -693,8 +693,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_TraitCount_UserIds_UserTraitsPrior_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.UserTraits_itemUserIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.userTrait_B[observation], this.userTraitsPrior, this.UserTraits_use_F_marginal, this.userIds, observation, this.UserTraits_itemUserIds_observation__F[observation]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.UserTraits_itemUserIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.userTrait_B[observation], this.UserTraitsPrior, this.UserTraits_use_F_marginal, this.UserIds, observation, this.UserTraits_itemUserIds_observation__F[observation]);
}
this.Changed_ObservationCount_TraitCount_UserIds_UserTraitsPrior_isDone = true;
}
@ -705,8 +705,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserBiasPrior_UserIds_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.UserBias_itemUserIds_observation__F[observation] = GetItemsOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian>(this.userBiasObs_B[observation], this.userBiasPrior, this.UserBias_use_F_marginal, this.userIds, observation, this.UserBias_itemUserIds_observation__F[observation]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.UserBias_itemUserIds_observation__F[observation] = GetItemsOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian>(this.userBiasObs_B[observation], this.UserBiasPrior, this.UserBias_use_F_marginal, this.UserIds, observation, this.UserBias_itemUserIds_observation__F[observation]);
this.vdouble163_F[observation] = GaussianProductOp_SHG09.ProductAverageConditional(this.UserBias_itemUserIds_observation__F[observation], 1.0, this.userBiasObs_B[observation]);
}
this.Changed_ObservationCount_UserBiasPrior_UserIds_isDone = true;
@ -718,9 +718,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserIds_UserThresholdCount_UserThresholdNoiseVariance_UserThresholdsPrior_U28_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
this.vdouble__89_F[observation][userThreshold] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.vdouble__88_F[observation][userThreshold], this.userThresholdNoiseVariance);
for(int observation = 0; observation<this.ObservationCount; observation++) {
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
this.vdouble__89_F[observation][userThreshold] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.vdouble__88_F[observation][userThreshold], this.UserThresholdNoiseVariance);
}
}
this.Changed_ObservationCount_UserIds_UserThresholdCount_UserThresholdNoiseVariance_UserThresholdsPrior_U28_isDone = true;
@ -732,14 +732,14 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserIds_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
if (!this.useSharedUserThresholds) {
if (!this.useSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.UserThresholdsObs_B[observation], this.userThresholdsPrior, this.UserThresholds_use_F_marginal, this.userIds, observation, this.UserThresholds_itemUserIds_observation__F[observation]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
if (!this.UseSharedUserThresholds) {
if (!this.UseSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F[observation] = GetItemsOp<double[]>.ItemsAverageConditional<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.UserThresholdsObs_B[observation], this.UserThresholdsPrior, this.UserThresholds_use_F_marginal, this.UserIds, observation, this.UserThresholds_itemUserIds_observation__F[observation]);
}
}
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
if (!this.useSharedUserThresholds) {
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
if (!this.UseSharedUserThresholds) {
this.UserThresholdsObs_F[observation][userThreshold] = ArrayHelper.SetTo<Gaussian>(this.UserThresholdsObs_F[observation][userThreshold], this.UserThresholds_itemUserIds_observation__F[observation][userThreshold]);
}
this.vdouble__88_F[observation][userThreshold] = GaussianProductOp_SHG09.ProductAverageConditional(this.UserThresholdsObs_F[observation][userThreshold], 1.0, this.UserThresholdsObs_B_reduced);
@ -754,8 +754,8 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserIds_UserTraitsPrior_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.UserTraits_itemUserIds_observation__F[observation] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.userTraitsPrior[this.userIds[observation]]);
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.UserTraits_itemUserIds_observation__F[observation] = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.UserTraitsPrior[this.UserIds[observation]]);
}
this.Changed_ObservationCount_UserIds_UserTraitsPrior_isDone = true;
}
@ -766,54 +766,54 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserThresholdCount_isDone) {
return ;
}
if (this.observationCount>0) {
if (this.ObservationCount>0) {
this.Ratings_F_reduced = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.vint45));
}
this.UserThresholdsObs_B_reduced = default(Gaussian);
if (this.observationCount>0) {
if (this.userThresholdCount>0) {
if (this.ObservationCount>0) {
if (this.UserThresholdCount>0) {
this.UserThresholdsObs_B_reduced = Gaussian.Uniform();
}
}
for(int observation = 0; observation<this.observationCount; observation++) {
this.UserThresholdsObs_B[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.UserThresholdsObs_B[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
this.UserThresholdsObs_B[observation][userThreshold] = this.UserThresholdsObs_B_reduced;
}
}
if (this.observationCount>0) {
if (this.ObservationCount>0) {
this.CurrentRating_reduced = new int[this.vint45];
}
for(int ratingValue = 0; ratingValue<this.vint45; ratingValue++) {
if (this.observationCount>0) {
if (this.ObservationCount>0) {
this.CurrentRating_reduced[ratingValue] = Factor.Plus(ratingValue, 0);
}
}
if (this.observationCount>0) {
if (this.ObservationCount>0) {
this.NextRating_reduced = new int[this.vint45];
}
for(int ratingValue = 0; ratingValue<this.vint45; ratingValue++) {
if (this.observationCount>0) {
if (this.ObservationCount>0) {
this.NextRating_reduced[ratingValue] = Factor.Plus(ratingValue, 1);
}
}
this.vbool9_reduced = default(bool);
if (this.observationCount>0) {
if (this.ObservationCount>0) {
if (this.vint45>0) {
this.vbool9_reduced = true;
}
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
this.Ratings_marginal_F[observation] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.vint45));
this.Ratings_observation__selector_uses_B[observation][2] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.vint45));
this.Ratings_observation__selector_uses_B[observation][1] = ArrayHelper.MakeUniform<Discrete>(Discrete.Uniform(this.vint45));
this.Ratings_observation__selector_cases_uses_B[observation] = new Bernoulli[this.vint45][];
this.Ratings_observation__selector_cases_B[observation] = new DistributionStructArray<Bernoulli,bool>(this.vint45);
this.true_logZ[observation] = new double[this.vint45];
this.vdouble__88_F[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
this.UserThresholdsObs_F[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
this.vdouble__89_F[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
this.vdouble__88_F[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
this.UserThresholdsObs_F[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
this.vdouble__89_F[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
this.vdouble__88_F[observation][userThreshold] = Gaussian.Uniform();
this.vdouble__89_F[observation][userThreshold] = Gaussian.Uniform();
}
@ -843,15 +843,15 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone) {
return ;
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (this.useSharedUserThresholds) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (this.UseSharedUserThresholds) {
this.UserThresholds_depth2_rep_F[_gi][observation] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.UserThresholdsObs_B_reduced, this.UserThresholds_depth2_rep_F_marginal[_gi], observation, this.UserThresholds_depth2_rep_F[_gi][observation]);
this.UserThresholds_0__gi_0__F[observation][_gi] = ArrayHelper.SetTo<Gaussian>(this.UserThresholds_0__gi_0__F[observation][_gi], this.UserThresholds_depth2_rep_F[_gi][observation]);
}
}
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
if (this.useSharedUserThresholds) {
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
if (this.UseSharedUserThresholds) {
this.UserThresholdsObs_F[observation][userThreshold] = ArrayHelper.SetTo<Gaussian>(this.UserThresholdsObs_F[observation][userThreshold], this.UserThresholds_0__gi_0__F[observation][userThreshold]);
}
}
@ -865,37 +865,37 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UserThresholdCount_UseSharedUserThresholds_isDone) {
return ;
}
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (this.useSharedUserThresholds) {
this.UserThresholds_depth2_rep_F[_gi] = new Gaussian[this.observationCount];
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (this.UseSharedUserThresholds) {
this.UserThresholds_depth2_rep_F[_gi] = new Gaussian[this.ObservationCount];
}
}
for(int observation = 0; observation<this.observationCount; observation++) {
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (this.useSharedUserThresholds) {
for(int observation = 0; observation<this.ObservationCount; observation++) {
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (this.UseSharedUserThresholds) {
this.UserThresholds_depth2_rep_F[_gi][observation] = Gaussian.Uniform();
}
}
if (!this.useSharedUserThresholds) {
if (!this.useSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
if (!this.UseSharedUserThresholds) {
if (!this.UseSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
}
}
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (!this.useSharedUserThresholds) {
if (!this.useSharedUserThresholds) {
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (!this.UseSharedUserThresholds) {
if (!this.UseSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F[observation][_gi] = Gaussian.Uniform();
}
}
}
for(int userThreshold = 0; userThreshold<this.userThresholdCount; userThreshold++) {
for(int userThreshold = 0; userThreshold<this.UserThresholdCount; userThreshold++) {
this.UserThresholdsObs_F[observation][userThreshold] = Gaussian.Uniform();
}
if (this.useSharedUserThresholds) {
this.UserThresholds_0__gi_0__F[observation] = new DistributionStructArray<Gaussian,double>(this.userThresholdCount);
if (this.UseSharedUserThresholds) {
this.UserThresholds_0__gi_0__F[observation] = new DistributionStructArray<Gaussian,double>(this.UserThresholdCount);
}
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (this.useSharedUserThresholds) {
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (this.UseSharedUserThresholds) {
this.UserThresholds_0__gi_0__F[observation][_gi] = Gaussian.Uniform();
}
}
@ -909,10 +909,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_ObservationCount_UseSharedUserThresholds_isDone) {
return ;
}
this.UserThresholds_0__gi_0__F = new DistributionStructArray<Gaussian,double>[this.observationCount];
if (!this.useSharedUserThresholds) {
if (!this.useSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.observationCount);
this.UserThresholds_0__gi_0__F = new DistributionStructArray<Gaussian,double>[this.ObservationCount];
if (!this.UseSharedUserThresholds) {
if (!this.UseSharedUserThresholds) {
this.UserThresholds_itemUserIds_observation__F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ObservationCount);
}
}
this.Changed_ObservationCount_UseSharedUserThresholds_isDone = true;
@ -924,9 +924,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserBiasPrior_isDone) {
return ;
}
this.UserBias_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.userBiasPrior);
this.UserBias_use_F_marginal = GetItemsOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.userBiasPrior);
this.UserBias_use_F_marginal = GetItemsOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.userBiasPrior, this.UserBias_use_B, this.UserBias_use_F_marginal);
this.UserBias_use_B = ArrayHelper.MakeUniform<DistributionStructArray<Gaussian,double>>(this.UserBiasPrior);
this.UserBias_use_F_marginal = GetItemsOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.UserBiasPrior);
this.UserBias_use_F_marginal = GetItemsOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.UserBiasPrior, this.UserBias_use_B, this.UserBias_use_F_marginal);
this.Changed_UserBiasPrior_isDone = true;
}
@ -936,7 +936,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserThresholdCount_isDone) {
return ;
}
this.vint45 = Factor.Difference(this.userThresholdCount, 1);
this.vint45 = Factor.Difference(this.UserThresholdCount, 1);
this.Changed_UserThresholdCount_isDone = true;
}
@ -946,11 +946,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone) {
return ;
}
for(int _gi = 0; _gi<this.userThresholdCount; _gi++) {
if (this.useSharedUserThresholds) {
this.UserThresholds_depth2_rep_B_toDef[_gi] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.userThresholdsPrior[0][_gi]);
this.UserThresholds_depth2_rep_F_marginal[_gi] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.userThresholdsPrior[0][_gi]);
this.UserThresholds_depth2_rep_F_marginal[_gi] = ReplicateOp_Divide.Marginal<Gaussian>(this.UserThresholds_depth2_rep_B_toDef[_gi], this.userThresholdsPrior[0][_gi], this.UserThresholds_depth2_rep_F_marginal[_gi]);
for(int _gi = 0; _gi<this.UserThresholdCount; _gi++) {
if (this.UseSharedUserThresholds) {
this.UserThresholds_depth2_rep_B_toDef[_gi] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.UserThresholdsPrior[0][_gi]);
this.UserThresholds_depth2_rep_F_marginal[_gi] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.UserThresholdsPrior[0][_gi]);
this.UserThresholds_depth2_rep_F_marginal[_gi] = ReplicateOp_Divide.Marginal<Gaussian>(this.UserThresholds_depth2_rep_B_toDef[_gi], this.UserThresholdsPrior[0][_gi], this.UserThresholds_depth2_rep_F_marginal[_gi]);
}
}
this.Changed_UserThresholdCount_UserThresholdsPrior_UseSharedUserThresholds_isDone = true;
@ -962,10 +962,10 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserThresholdCount_UseSharedUserThresholds_isDone) {
return ;
}
if (this.useSharedUserThresholds) {
this.UserThresholds_depth2_rep_F = new Gaussian[this.userThresholdCount][];
this.UserThresholds_depth2_rep_F_marginal = new Gaussian[this.userThresholdCount];
this.UserThresholds_depth2_rep_B_toDef = new Gaussian[this.userThresholdCount];
if (this.UseSharedUserThresholds) {
this.UserThresholds_depth2_rep_F = new Gaussian[this.UserThresholdCount][];
this.UserThresholds_depth2_rep_F_marginal = new Gaussian[this.UserThresholdCount];
this.UserThresholds_depth2_rep_B_toDef = new Gaussian[this.UserThresholdCount];
}
this.Changed_UserThresholdCount_UseSharedUserThresholds_isDone = true;
}
@ -976,7 +976,7 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserThresholdsPrior_isDone) {
return ;
}
this.UserThresholds_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.userThresholdsPrior);
this.UserThresholds_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.UserThresholdsPrior);
this.Changed_UserThresholdsPrior_isDone = true;
}
@ -986,11 +986,11 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserThresholdsPrior_UseSharedUserThresholds_isDone) {
return ;
}
if (!this.useSharedUserThresholds) {
if (!this.useSharedUserThresholds) {
this.UserThresholds_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.userThresholdsPrior);
if (!this.UseSharedUserThresholds) {
if (!this.UseSharedUserThresholds) {
this.UserThresholds_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.UserThresholdsPrior);
}
this.UserThresholds_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.userThresholdsPrior, this.UserThresholds_use_B, this.UserThresholds_use_F_marginal);
this.UserThresholds_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.UserThresholdsPrior, this.UserThresholds_use_B, this.UserThresholds_use_F_marginal);
}
this.Changed_UserThresholdsPrior_UseSharedUserThresholds_isDone = true;
}
@ -1001,9 +1001,9 @@ namespace Microsoft.ML.Probabilistic.Learners.MatchboxRecommenderInternal
if (this.Changed_UserTraitsPrior_isDone) {
return ;
}
this.UserTraits_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.userTraitsPrior);
this.UserTraits_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.userTraitsPrior);
this.UserTraits_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.userTraitsPrior, this.UserTraits_use_B, this.UserTraits_use_F_marginal);
this.UserTraits_use_B = ArrayHelper.MakeUniform<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.UserTraitsPrior);
this.UserTraits_use_F_marginal = GetItemsOp<double[]>.MarginalInit<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>>(this.UserTraitsPrior);
this.UserTraits_use_F_marginal = GetItemsOp<double[]>.Marginal<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,DistributionStructArray<Gaussian,double>>(this.UserTraitsPrior, this.UserTraits_use_B, this.UserTraits_use_F_marginal);
this.Changed_UserTraitsPrior_isDone = true;
}

Просмотреть файл

@ -31,6 +31,10 @@ namespace Microsoft.ML.Probabilistic.Serialization
public void Write(string value)
{
if (value.Contains(Environment.NewLine))
{
throw new ArgumentException("string contains newline", value);
}
writer.WriteLine(value);
}

Просмотреть файл

@ -292,7 +292,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="CasesOp"]/message_doc[@name="BAverageConditional(IList{Bernoulli})"]/*'/>
public static Bernoulli BAverageConditional([SkipIfUniform] IList<Bernoulli> cases)
public static Bernoulli BAverageConditional([SkipIfAllUniform] IList<Bernoulli> cases)
{
// result = p(b=true) / (p(b=true) + p(b=false))
// = 1 / (1 + p(b=false)/p(b=true))
@ -312,7 +312,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="CasesOp"]/message_doc[@name="LogEvidenceRatio(IList{Bernoulli}, Bernoulli)"]/*'/>
public static double LogEvidenceRatio(IList<Bernoulli> cases, Bernoulli b)
public static double LogEvidenceRatio([SkipIfAllUniform] IList<Bernoulli> cases, Bernoulli b)
{
// result = log (p(data|b=true) p(b=true) + p(data|b=false) p(b=false))
// log (p(data|b=true) p(b=true) + p(data|b=false) (1-p(b=true))
@ -377,13 +377,13 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="CasesOp"]/message_doc[@name="BAverageLogarithm(IList{Bernoulli})"]/*'/>
public static Bernoulli BAverageLogarithm([SkipIfUniform] IList<Bernoulli> cases) // TM: SkipIfAny (rather than SkipIfAll) is important for getting good schedules
public static Bernoulli BAverageLogarithm([SkipIfAllUniform] IList<Bernoulli> cases)
{
return BAverageConditional(cases);
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="CasesOp"]/message_doc[@name="AverageLogFactor(IList{Bernoulli}, Bernoulli)"]/*'/>
public static double AverageLogFactor([SkipIfUniform] IList<Bernoulli> cases, Bernoulli b)
public static double AverageLogFactor([SkipIfAllUniform] IList<Bernoulli> cases, Bernoulli b)
{
double probTrue = b.GetProbTrue();
return probTrue * cases[0].LogOdds + (1 - probTrue) * cases[1].LogOdds;
@ -483,7 +483,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="IntCasesOp"]/message_doc[@name="IAverageConditional(IList{Bernoulli}, Discrete)"]/*'/>
public static Discrete IAverageConditional([SkipIfUniform] IList<Bernoulli> cases, Discrete result)
public static Discrete IAverageConditional([SkipIfAllUniform] IList<Bernoulli> cases, Discrete result)
{
Vector probs = result.GetWorkspace();
double max = cases[0].LogOdds;
@ -518,7 +518,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="IntCasesOp"]/message_doc[@name="LogEvidenceRatio(IList{Bernoulli}, Discrete)"]/*'/>
public static double LogEvidenceRatio([SkipIfUniform] IList<Bernoulli> cases, Discrete i)
public static double LogEvidenceRatio([SkipIfAllUniform] IList<Bernoulli> cases, Discrete i)
{
if (i.IsPointMass)
return cases[i.Point].LogOdds;
@ -534,7 +534,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="IntCasesOp"]/message_doc[@name="LogEvidenceRatio(IList{Bernoulli}, int)"]/*'/>
public static double LogEvidenceRatio(IList<Bernoulli> cases, int i)
public static double LogEvidenceRatio([SkipIfAllUniform] IList<Bernoulli> cases, int i)
{
return cases[i].LogOdds;
}
@ -555,7 +555,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="IntCasesOp"]/message_doc[@name="IAverageLogarithm(IList{Bernoulli}, Discrete)"]/*'/>
public static Discrete IAverageLogarithm([SkipIfUniform] IList<Bernoulli> cases, Discrete result)
public static Discrete IAverageLogarithm([SkipIfAllUniform] IList<Bernoulli> cases, Discrete result)
{
return IAverageConditional(cases, result);
}

Просмотреть файл

@ -68,9 +68,7 @@ namespace Microsoft.ML.Probabilistic.Factors
{
if (array[i].Precision == 0)
return array[i];
double mean1;
double variance1;
array[i].GetMeanAndVarianceImproper(out mean1, out variance1);
array[i].GetMeanAndVarianceImproper(out double mean1, out double variance1);
mean = mean + mean1;
variance = variance + variance1;
}
@ -97,15 +95,13 @@ namespace Microsoft.ML.Probabilistic.Factors
}
return result;
}
double sumMean, sumVariance;
sum.GetMeanAndVarianceImproper(out sumMean, out sumVariance);
sum.GetMeanAndVarianceImproper(out double sumMean, out double sumVariance);
// Check if an element of the array is uniform.
int indexOfUniform = -1;
for (int i = 0; i < array.Count; i++)
{
double meani, variancei;
array[i].GetMeanAndVarianceImproper(out meani, out variancei);
array[i].GetMeanAndVarianceImproper(out double meani, out double variancei);
// instead of testing IsUniform, we need to test the more strict requirement
// of variance < Infinity due to the way we are doing the computations
if (double.IsPositiveInfinity(variancei))
@ -137,8 +133,7 @@ namespace Microsoft.ML.Probabilistic.Factors
// at this point, the array has no uniform elements.
// get the mean and variance of sum of all the Gaussians;
double totalMean, totalVariance;
to_sum.GetMeanAndVarianceImproper(out totalMean, out totalVariance);
to_sum.GetMeanAndVarianceImproper(out double totalMean, out double totalVariance);
// subtract it off from the mean and variance of incoming Gaussian from Sum
double totalMsgMean = sumMean - totalMean;
@ -146,8 +141,7 @@ namespace Microsoft.ML.Probabilistic.Factors
for (int i = 0; i < array.Count; i++)
{
double meani, variancei;
array[i].GetMeanAndVarianceImproper(out meani, out variancei);
array[i].GetMeanAndVarianceImproper(out double meani, out double variancei);
double msgMean = totalMsgMean + meani;
double msgVariance = totalMsgVariance - variancei;
if (Math.Abs(msgVariance) < Math.Abs(totalMsgVariance) * 1e-10)

Просмотреть файл

@ -144,7 +144,7 @@ namespace Microsoft.ML.Probabilistic.Factors
int previousUpdateCount = 0;
public double nextPoint;
double scaleUp = 2;
int boundScaleUp = 2;
const int boundScaleUp = 2;
double stepsize;
double stepsizeUpperBound = double.PositiveInfinity;
public double lowerBound = double.NegativeInfinity, upperBound = double.PositiveInfinity;

Просмотреть файл

@ -6,8 +6,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ML.Probabilistic.Distributions;
using Microsoft.ML.Probabilistic.Models;
using Range = Microsoft.ML.Probabilistic.Models.Range;
namespace Microsoft.ML.Probabilistic.Tutorials
@ -85,7 +87,7 @@ namespace Microsoft.ML.Probabilistic.Tutorials
using (Variable.IfNot(doB[N]))
{
// Set B to a noisy version of A
B[N] = A[N] != (Variable.Bernoulli(q));
B[N] = A[N] != Variable.Bernoulli(q);
}
}
}
@ -103,7 +105,7 @@ namespace Microsoft.ML.Probabilistic.Tutorials
B[N] = Variable.Bernoulli(0.5);
}
// Set A to a noisy version of B
A[N] = B[N] != (Variable.Bernoulli(q));
A[N] = B[N] != Variable.Bernoulli(q);
}
}
@ -113,56 +115,66 @@ namespace Microsoft.ML.Probabilistic.Tutorials
var engine = new InferenceEngine();
Console.WriteLine("Causal inference using gates in Infer.NET");
Console.WriteLine("=========================================\r\n");
Console.WriteLine("Data set of " + numberOfDataPoints + " data points with noise " + q + "\r\n");
Console.WriteLine("Data set of " + numberOfDataPoints + " data points with noise " + q);
// *** Data without interventions ***
// Generate data set
var dataWithoutInterventions = GenerateFromTrueModel(numberOfDataPoints, q, false, probBIntervention);
// Attach the data without interventions
A.ObservedValue = dataWithoutInterventions.A;
B.ObservedValue = dataWithoutInterventions.B;
doB.ObservedValue = dataWithoutInterventions.doB;
// Infer probability that A causes B (rather than B causes A)
Bernoulli AcausesBdist = engine.Infer<Bernoulli>(AcausesB);
Console.WriteLine("P(A causes B), without interventions=" + AcausesBdist.GetProbTrue() + "\r\n");
// *** Data WITH interventions ***
// Number of inference runs to average over (each with a different generated data set)
int numberOfRuns = 10;
Console.WriteLine("Executing " + numberOfRuns + " runs with interventions:");
double tot = 0;
for (int i = 0; i < numberOfRuns; i++)
foreach (bool generateFromAcausesB in new bool[] { true, false })
{
// Generate data with interventions
var dataWithInterventions = GenerateFromTrueModel(numberOfDataPoints, q, true, probBIntervention);
Console.WriteLine();
Console.WriteLine("Generating data where " + (generateFromAcausesB ? "A causes B" : "B causes A"));
// *** Data without interventions ***
// Generate data set
var dataWithoutInterventions = GenerateFromTrueModel(numberOfDataPoints, q, false, probBIntervention, generateFromAcausesB);
// Attach the data with interventions (this replaces any previously attached data)
A.ObservedValue = dataWithInterventions.A;
B.ObservedValue = dataWithInterventions.B;
doB.ObservedValue = dataWithInterventions.doB;
// Attach the data without interventions
A.ObservedValue = dataWithoutInterventions.A;
B.ObservedValue = dataWithoutInterventions.B;
doB.ObservedValue = dataWithoutInterventions.doB;
// Infer probability that A causes B (rather than B causes A)
Bernoulli AcausesBdist2 = engine.Infer<Bernoulli>(AcausesB);
tot += AcausesBdist2.GetProbTrue();
Console.WriteLine("{0,4}. P(A causes B)={1}", i + 1, (float)AcausesBdist2.GetProbTrue());
}
Console.WriteLine("Average P(A causes B), with interventions=" + (float)(tot / numberOfRuns));
Bernoulli AcausesBdist = engine.Infer<Bernoulli>(AcausesB);
Console.WriteLine("P(A causes B), without interventions=" + AcausesBdist.GetProbTrue());
// *** Data WITH interventions ***
// Number of inference runs to average over (each with a different generated data set)
int numberOfRuns = 10;
Console.WriteLine("Executing " + numberOfRuns + " runs with interventions:");
double tot = 0;
for (int i = 0; i < numberOfRuns; i++)
{
// Generate data with interventions
var dataWithInterventions = GenerateFromTrueModel(numberOfDataPoints, q, true, probBIntervention, generateFromAcausesB);
// Attach the data with interventions (this replaces any previously attached data)
A.ObservedValue = dataWithInterventions.A;
B.ObservedValue = dataWithInterventions.B;
doB.ObservedValue = dataWithInterventions.doB;
// Infer probability that A causes B (rather than B causes A)
Bernoulli AcausesBdist2 = engine.Infer<Bernoulli>(AcausesB);
tot += AcausesBdist2.GetProbTrue();
Console.WriteLine("{0,4}. P(A causes B)={1}", i + 1, (float)AcausesBdist2.GetProbTrue());
}
Console.WriteLine("Average P(A causes B), with interventions=" + (float)(tot / numberOfRuns));
}
}
private static Data GenerateFromTrueModel(int N, double q, bool doB, double probBIntervention, bool AcausesB)
{
return AcausesB
? GenerateFromAcausesB(N, q, doB, probBIntervention)
: GenerateFromBcausesA(N, q, doB, probBIntervention);
}
/// <summary>
/// Generates data from the true model: A cause B
/// Generates data from the true model: A causes B
/// </summary>
/// <param name="N">Number of data points to generate</param>
/// <param name="q">Noise (flip) probability</param>
/// <param name="doB">Whether to intervene or not</param>
/// <param name="probBIntervention">Prob of choosing B=true when intervening</param>
/// <returns></returns>
private static Data GenerateFromTrueModel(int N, double q, bool doB, double probBIntervention)
private static Data GenerateFromAcausesB(int N, double q, bool doB, double probBIntervention)
{
// Create data object to fill with data.
Data d = new Data { A = new bool[N], B = new bool[N], doB = new bool[N] };
@ -198,16 +210,49 @@ namespace Microsoft.ML.Probabilistic.Tutorials
}
return d;
}
}
/// <summary>
/// Generates data from the true model: B causes A
/// </summary>
/// <param name="N">Number of data points to generate</param>
/// <param name="q">Noise (flip) probability</param>
/// <param name="doB">Whether to intervene or not</param>
/// <param name="probBIntervention">Prob of choosing B=true when intervening</param>
/// <returns></returns>
private static Data GenerateFromBcausesA(int N, double q, bool doB, double probBIntervention)
{
// Create data object to fill with data.
Data d = new Data { A = new bool[N], B = new bool[N], doB = new bool[N] };
/// <summary>
/// Class to store the data
/// </summary>
class Data
{
public bool[] A; // observations of A
public bool[] B; // observations of B
public bool[] doB; // whether we intervened to set B
var Bprior = new Bernoulli(0.5);
// Noise distribution
var flipDist = new Bernoulli(q);
// Distribution over the values of B when we intervene
var interventionDist = new Bernoulli(probBIntervention);
// Loop over data
for (int i = 0; i < N; i++)
{
d.B[i] = doB ? interventionDist.Sample() : Bprior.Sample();
// Draw A from prior
d.A[i] = d.B[i] != flipDist.Sample();
// Whether we intervened on B
// This is currently the same for all data points - but could easily be modified.
d.doB[i] = doB;
}
return d;
}
/// <summary>
/// Class to store the data
/// </summary>
class Data
{
public bool[] A; // observations of A
public bool[] B; // observations of B
public bool[] doB; // whether we intervened to set B
}
}
}

Просмотреть файл

@ -13,6 +13,13 @@ namespace Microsoft.ML.Probabilistic.Tutorials
{
public class WetGlassSprinklerRainModel
{
// Although all the variables in this example have just 2 states (true/false),
// the example is formulated in a way that shows how to extend to multiple states
public const int CloudyStateCount = 2;
public const int SprinklerStateCount = 2;
public const int RainStateCount = 2;
public const int WetGrassStateCount = 2;
// Primary random variables
public VariableArray<int> Cloudy;
public VariableArray<int> Sprinkler;
@ -54,12 +61,10 @@ namespace Microsoft.ML.Probabilistic.Tutorials
NumberOfExamples = Variable.New<int>().Named("NofE");
Range N = new Range(NumberOfExamples).Named("N");
// Although all the variables in this example have just 2 states (true/false),
// the example is formulated in a way that shows how to extend to multiple states
Range C = new Range(2).Named("C");
Range S = new Range(2).Named("S");
Range R = new Range(2).Named("R");
Range W = new Range(2).Named("W");
Range C = new Range(CloudyStateCount).Named("C");
Range S = new Range(SprinklerStateCount).Named("S");
Range R = new Range(RainStateCount).Named("R");
Range W = new Range(WetGrassStateCount).Named("W");
// Define the priors and the parameters
ProbCloudyPrior = Variable.New<Dirichlet>().Named("ProbCloudyPrior");
@ -144,11 +149,13 @@ namespace Microsoft.ML.Probabilistic.Tutorials
int[] wetgrass)
{
// Set all priors to uniform
Dirichlet probCloudyPrior = Dirichlet.Uniform(2);
Dirichlet[] dirUnifArray = Enumerable.Repeat(Dirichlet.Uniform(2), 2).ToArray();
Dirichlet[][] dirUnifArrayArray = Enumerable.Repeat(dirUnifArray, 2).ToArray();
Dirichlet probCloudyPrior = Dirichlet.Uniform(CloudyStateCount);
Dirichlet[] cptSprinklerPrior = Enumerable.Repeat(Dirichlet.Uniform(SprinklerStateCount), CloudyStateCount).ToArray();
Dirichlet[] cptRainPrior = Enumerable.Repeat(Dirichlet.Uniform(RainStateCount), CloudyStateCount).ToArray();
Dirichlet[] dirUnifArray = Enumerable.Repeat(Dirichlet.Uniform(WetGrassStateCount), RainStateCount).ToArray();
Dirichlet[][] cptWetGrassPrior = Enumerable.Repeat(dirUnifArray, SprinklerStateCount).ToArray();
LearnParameters(cloudy, sprinkler, rain, wetgrass, probCloudyPrior, dirUnifArray, dirUnifArray, dirUnifArrayArray);
LearnParameters(cloudy, sprinkler, rain, wetgrass, probCloudyPrior, cptSprinklerPrior, cptRainPrior, cptWetGrassPrior);
}
/// <summary>

Просмотреть файл

@ -2423,8 +2423,8 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
{
0.109666345041522, -0.062557928550261, -0.827699303548466
}),
new PositiveDefiniteMatrix(new double[,]
{
new PositiveDefiniteMatrix(new double[,]
{
{ 0.004203498829365, -0.002901565701299, -0.012119192593608},
{-0.002901565701299, 0.003226764582933, -0.016479796269154},
{-0.012119192593608, -0.016479796269154, 0.843335367330159}
@ -2471,7 +2471,7 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
//Console.WriteLine(wActual);
Vector mwTrue = Vector.FromArray(-1.178410192370038, 0.514204026416866, 0.533030909628306);
PositiveDefiniteMatrix vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.3578619594789516, 0.05893838160003953, -0.1183834842062737,},
{0.05893838160003954, 0.5424263963482457, -0.08091881706709862,},
{-0.1183834842062736, -0.08091881706709868, 0.1625333312892799,}
@ -2519,11 +2519,11 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
Console.WriteLine(wActual);
Vector mwTrue = Vector.FromArray(-1.077521554289827, -0.2008897723072238, 0.3660247485925804);
PositiveDefiniteMatrix vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.5410449066272626,0.07674046058414256,-0.161630781607686},
{0.07674046058414252,0.4505294996327321,-0.213693905957742},
{-0.161630781607686, -0.213693905957742, 0.3821742571834561}
});
{-0.161630781607686, -0.213693905957742, 0.3821742571834561}
});
VectorGaussian wExpected = new VectorGaussian(mwTrue, vwTrue);
Assert.True(wExpected.MaxDiff(wActual) < 1e-6);
@ -2567,18 +2567,18 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
// error rate = 0.1
Vector mwTrue = Vector.FromArray(-1.16220429443624, -0.0338583325319568, 0.5428335422151358);
PositiveDefiniteMatrix vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.3730596036503481,0.09642738507267575,-0.1256797047507377},
{0.09642738507267563,0.7684442285629477,-0.1530917637786459},
{-0.1256797047507378, -0.1530917637786461, 0.2119627016754658}
});
{-0.1256797047507378, -0.1530917637786461, 0.2119627016754658}
});
double tolerance = 1e-6;
double evExpected = -4.553117742706541;
if (FactorManager.IsDefaultOperator(typeof(IsPositiveOp_Proper)))
{
mwTrue = Vector.FromArray(-1.164, -0.07971, 0.5411);
vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.3656, 0.09801, -0.1145},
{0.09801, 0.5187, -0.1651},
{-0.1145, -0.1651, 0.1929}
@ -2628,7 +2628,7 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
//Console.WriteLine(wActual);
Vector mwTrue = Vector.FromArray(-1.178410192370038, 0.514204026416866, 0.533030909628306);
PositiveDefiniteMatrix vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.3578619594789516, 0.05893838160003953, -0.1183834842062737,},
{0.05893838160003954, 0.5424263963482457, -0.08091881706709862,},
{-0.1183834842062736, -0.08091881706709868, 0.1625333312892799,}
@ -2720,7 +2720,7 @@ new double[] {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
{
mwTrue = Vector.FromArray(-1.164, -0.07971, 0.5411);
vwTrue = new PositiveDefiniteMatrix(new double[,]
{
{
{0.3656, 0.09801, -0.1145},
{0.09801, 0.5187, -0.1651},
{-0.1145, -0.1651, 0.1929}

Просмотреть файл

@ -4,13 +4,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.ML.Probabilistic.Algorithms;
using Microsoft.ML.Probabilistic.Models.Attributes;
using Microsoft.ML.Probabilistic.Models;
using Microsoft.ML.Probabilistic.Factors;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Distributions;
using Microsoft.ML.Probabilistic.Math;
using Microsoft.ML.Probabilistic.Utilities;
using Xunit;
using Range = Microsoft.ML.Probabilistic.Models.Range;
namespace Microsoft.ML.Probabilistic.Tests
{
@ -21,10 +24,6 @@ namespace Microsoft.ML.Probabilistic.Tests
using Assert = Microsoft.ML.Probabilistic.Tests.AssertHelper;
using BernoulliArray = DistributionStructArray<Bernoulli, bool>;
using BernoulliArrayArray = DistributionRefArray<DistributionStructArray<Bernoulli, bool>, bool[]>;
using Microsoft.ML.Probabilistic.Compiler;
using System.Diagnostics;
using Microsoft.ML.Probabilistic.Algorithms;
using Microsoft.ML.Probabilistic.Models.Attributes;
using Range = Microsoft.ML.Probabilistic.Models.Range;
public class GateModelTests
@ -56,7 +55,7 @@ namespace Microsoft.ML.Probabilistic.Tests
}
[Fact]
public void ForEachIfObservedTest()
public void ForEachIfObservedConstrainTrueTest()
{
Range item = new Range(2).Named("item");
VariableArray<bool> array1 = Variable.Observed(new[] { false, true }, item).Named("array1");
@ -2337,7 +2336,7 @@ namespace Microsoft.ML.Probabilistic.Tests
}
[Fact]
public void IfObservedConditionTest4()
public void ForEachIfObservedConstrainEqualRandomTest()
{
double pT = 0.1;
double pF = 0.5;
@ -4573,6 +4572,41 @@ namespace Microsoft.ML.Probabilistic.Tests
}
}
[Fact]
public void IfExitObservedConditionTest2()
{
Variable<bool> b = Variable.New<bool>().Named("b");
Variable<bool> c = Variable.New<bool>().Named("c");
using (Variable.If(b))
{
c.SetTo(Variable.Bernoulli(0.125));
}
using (Variable.IfNot(b))
{
c.SetTo(Variable.Bernoulli(0.25));
}
var d = !c;
d.Name = nameof(d);
InferenceEngine engine = new InferenceEngine();
Bernoulli dExpected;
for (int trial = 0; trial < 2; trial++)
{
if (trial % 2 == 0)
{
b.ObservedValue = true;
dExpected = new Bernoulli(1 - 0.125);
}
else
{
b.ObservedValue = false;
dExpected = new Bernoulli(1 - 0.25);
}
Bernoulli dActual = engine.Infer<Bernoulli>(d);
Console.WriteLine("d = {0} should be {1}", dActual, dExpected);
Assert.True(dExpected.MaxDiff(dActual) < 1e-10);
}
}
[Fact]
public void IfRandomIfObservedIfRandomConditionTest()
{
@ -5116,7 +5150,7 @@ namespace Microsoft.ML.Probabilistic.Tests
}
[Fact]
public void IfObservedConditionTest()
public void IfObservedConstrainTrueTest()
{
Variable<bool> b = Variable.New<bool>().Named("b");
Variable<bool> c = Variable.Bernoulli(0.1).Named("c");
@ -5190,7 +5224,7 @@ namespace Microsoft.ML.Probabilistic.Tests
}
[Fact]
public void IfObservedConditionTest2()
public void IfObservedConstrainTrueElseTest()
{
Variable<bool> evidence = Variable.Bernoulli(0.5).Named("evidence");
IfBlock block = Variable.If(evidence);
@ -5232,7 +5266,7 @@ namespace Microsoft.ML.Probabilistic.Tests
}
[Fact]
public void IfObservedConditionTest3()
public void IfObservedConstrainEqualRandomTest()
{
Variable<bool> evidence = Variable.Bernoulli(0.5).Named("evidence");
IfBlock block = Variable.If(evidence);

Просмотреть файл

@ -2285,17 +2285,21 @@ namespace Microsoft.ML.Probabilistic.Tests
InferenceEngine engine = new InferenceEngine();
Discrete indexActual = engine.Infer<Discrete>(index);
});
Assert.Throws<ArgumentException>(() =>
{
Variable<int> index = Variable.Discrete(new Range(3), Vector.FromArray(new double[] { 0.2, 0.8 })).Named("index");
InferenceEngine engine = new InferenceEngine();
Discrete indexActual = engine.Infer<Discrete>(index);
});
}
[Fact]
public void DiscreteValueRangeError()
{
Assert.Throws<ArgumentException>(() =>
{
Range i = new Range(2);
Variable<Vector> probs = Variable.Dirichlet(i, new double[] { 1, 1 }).Named("probs");
Range j = new Range(2);
@ -2303,7 +2307,6 @@ namespace Microsoft.ML.Probabilistic.Tests
InferenceEngine engine = new InferenceEngine();
Discrete indexActual = engine.Infer<Discrete>(index);
});
}
@ -2324,11 +2327,9 @@ namespace Microsoft.ML.Probabilistic.Tests
[Fact]
public void DiscreteSizeError()
{
Assert.Throws<ArgumentException>(() =>
{
Variable<int> index = Variable.Discrete(6).Named("index");
InferenceEngine engine = new InferenceEngine();
@ -2336,7 +2337,6 @@ namespace Microsoft.ML.Probabilistic.Tests
Discrete indexExpected = Discrete.Uniform(6);
Console.WriteLine("index = {0} should be {1}", indexActual, indexExpected);
Assert.True(indexExpected.MaxDiff(indexActual) < 1e-10);
});
}
@ -2355,6 +2355,30 @@ namespace Microsoft.ML.Probabilistic.Tests
Assert.True(probsExpected.MaxDiff(probsActual) < 1e-10);
}
[Fact]
public void DirichletSizeError()
{
Assert.Throws<ArgumentException>(() =>
{
Range i = new Range(3);
Variable<Vector> probs = Variable.Dirichlet(i, new double[] { 1, 1 }).Named("probs");
InferenceEngine engine = new InferenceEngine();
Dirichlet probsActual = engine.Infer<Dirichlet>(probs);
});
Assert.Throws<ArgumentException>(() =>
{
Range i = new Range(3);
Variable<Vector> probs = Variable.Dirichlet(i, Vector.FromArray(new double[] { 1, 1 })).Named("probs");
InferenceEngine engine = new InferenceEngine();
Dirichlet probsActual = engine.Infer<Dirichlet>(probs);
});
}
[Fact]
public void SetToArrayError()
@ -3631,6 +3655,54 @@ namespace Microsoft.ML.Probabilistic.Tests
}
}
[Fact]
public void ObservedVariableNameClash()
{
Assert.Throws<InferCompilerException>(() =>
{
var x = Variable.Observed(1.0).Named("x");
var y = Variable.Observed(2.0).Named("x");
var z = (x + y).Named("z");
InferenceEngine engine = new InferenceEngine();
engine.Infer(z);
});
}
[Fact]
public void ObservedVariableNameCapitalisationClash()
{
var x = Variable.Observed(1.0).Named("x");
var y = Variable.Observed(2.0).Named("X");
var z = (x + y).Named("z");
InferenceEngine engine = new InferenceEngine();
engine.Infer(z);
engine.Infer(x);
engine.Infer(y);
}
[Fact]
public void InferredVariableNameClash()
{
Assert.Throws<InferCompilerException>(() =>
{
Variable<double> x = Variable.Beta(1, 1).Named("x");
Variable<bool> y = Variable.Bernoulli(x).Named("x");
InferenceEngine engine = new InferenceEngine();
engine.Infer(x);
engine.Infer(y);
});
}
[Fact]
public void InferredVariableNameCapitalisationClash()
{
Variable<double> x = Variable.Beta(1, 1).Named("x");
Variable<bool> x2 = Variable.Bernoulli(x).Named("X");
InferenceEngine engine = new InferenceEngine();
engine.Infer(x);
engine.Infer(x2);
}
[Fact]
public void RangeNameClashTest()
{