protected AbstractModel( Context[] parameters, string[] predLabels, string[] outcomeNames, int correctionConstant, double correctionParam) : this(predLabels, outcomeNames) { evalParameters = new EvalParameters(parameters, correctionParam, correctionConstant, outcomeNames.Length); }
/// <summary> /// Initializes a new instance of the <see cref="EvalParameters"/> which can be evaluated. /// </summary> /// <param name="parameters">The parameters of the model.</param> /// <param name="correctionParam">The correction parameter.</param> /// <param name="correctionConstant">The correction constant.</param> /// <param name="numOutcomes">The number outcomes.</param> public EvalParameters(Context[] parameters, double correctionParam, double correctionConstant, int numOutcomes) { Parameters = parameters; NumOutcomes = numOutcomes; CorrectionParam = correctionParam; CorrectionConstant = correctionConstant; // check if the double is "equal" to zero if (Math.Abs(correctionConstant) < 0.000001) ConstantInverse = 1/correctionConstant; else ConstantInverse = 1d; }
/// <summary> /// Creates a new model with the specified parameters, outcome names, and predicate/feature labels. /// </summary> /// <param name="parameters">The parameters of the model.</param> /// <param name="predLabels">The names of the predicates used in this model.</param> /// <param name="outcomeNames">The names of the outcomes this model predicts.</param> /// <param name="correctionConstant">The maximum number of active features which occur in an event.</param> /// <param name="correctionParam">The parameter associated with the correction feature.</param> /// <param name="prior">The prior to be used with this model.</param> public GISModel( Context[] parameters, string[] predLabels, string[] outcomeNames, int correctionConstant, double correctionParam, IPrior prior) : base(parameters, predLabels, outcomeNames, correctionConstant, correctionParam) { this.prior = prior; this.prior.SetLabels(outcomeNames, predLabels); ModelType = ModelType.Maxent; }
/// <summary> /// Initializes a new instance of the <see cref="EvalParameters"/> which can be evaluated. /// </summary> /// <param name="parameters">The parameters of the model.</param> /// <param name="numOutcomes">The number outcomes.</param> public EvalParameters(Context[] parameters, int numOutcomes) : this(parameters, 0, 0, numOutcomes) {}
public QNModel(Context[] parameters, string[] predLabels, string[] outcomeNames, int correctionConstant, double correctionParam) : base(parameters, predLabels, outcomeNames, correctionConstant, correctionParam) {}
public QNModel(Context[] parameters, IndexHashTable<string> map, string[] outcomeNames) : base(parameters, map, outcomeNames) {}
public QNModel(Context[] parameters, string[] predLabels, string[] outcomeNames) : base(parameters, predLabels, outcomeNames) {}
/// <summary> /// Creates a new model with the specified parameters, outcome names, and predicate/feature labels using the <see cref="UniformPrior"/> as prior. /// </summary> /// <param name="parameters">The parameters of the model.</param> /// <param name="predLabels">The names of the predicates used in this model.</param> /// <param name="outcomeNames">The names of the outcomes this model predicts.</param> /// <param name="correctionConstant">The maximum number of active features which occur in an event.</param> /// <param name="correctionParam">The parameter associated with the correction feature.</param> public GISModel(Context[] parameters, string[] predLabels, string[] outcomeNames, int correctionConstant, double correctionParam) : this(parameters, predLabels, outcomeNames, correctionConstant, correctionParam, new UniformPrior()) { ModelType = ModelType.Maxent; }
/// <summary> /// Reads the parameters from a file and populates an array of context objects. /// </summary> /// <param name="outcomePatterns">The outcomes patterns for the model. The first index refers to which /// outcome pattern (a set of outcomes that occurs with a context) is being specified. The /// second index specifies the number of contexts which use this pattern at index 0, and the /// index of each outcomes which make up this pattern in indices 1-n.</param> /// <returns>An array of context objects.</returns> protected Context[] GetParameters(int[][] outcomePatterns) { var par = new Context[NUM_PREDS]; var pid = 0; for (var i = 0; i < outcomePatterns.Length; i++) { //construct outcome pattern var outcomePattern = new int[outcomePatterns[i].Length - 1]; for (var k = 1; k < outcomePatterns[i].Length; k++) { outcomePattern[k - 1] = outcomePatterns[i][k]; } //populate parameters for each context which uses this outcome pattern. for (var j = 0; j < outcomePatterns[i][0]; j++) { var contextParameters = new double[outcomePatterns[i].Length - 1]; for (var k = 1; k < outcomePatterns[i].Length; k++) { contextParameters[k - 1] = ReadDouble(); } par[pid] = new Context(outcomePattern, contextParameters); pid++; } } return par; }
public PerceptronModel(Context[] parameters, string[] predLabels, string[] outcomeNames, int correctionConstant, double correctionParam) : base(parameters, predLabels, outcomeNames, correctionConstant, correctionParam) { ModelType = ModelType.Perceptron; }
public PerceptronModel(Context[] parameters, IndexHashTable<string> map, string[] outcomeNames) : base(parameters, map, outcomeNames) { ModelType = ModelType.Perceptron; }
public PerceptronModel(Context[] parameters, string[] predLabels, string[] outcomeNames) : base(parameters, predLabels, outcomeNames) { ModelType = ModelType.Perceptron; }
protected AbstractModel(Context[] parameters, string[] predLabels, IndexHashTable<string> map, string[] outcomeNames) { this.map = map; this.outcomeNames = outcomeNames; evalParameters = new EvalParameters(parameters, outcomeNames.Length); }
protected AbstractModel(Context[] parameters, string[] predLabels, string[] outcomeNames) : this(predLabels, outcomeNames) { evalParameters = new EvalParameters(parameters, outcomeNames.Length); }