/// <summary>
        /// Returns model information for a predicate, given the predicate label.
        /// </summary>
        /// <param name="predicateLabel">
        /// The predicate label to fetch information for.
        /// </param>
        /// <param name="featureCounts">
        /// Array to be passed in to the method; it should have a length equal to the number of outcomes
        /// in the model.  The method increments the count of each outcome that is active in the specified
        /// predicate.
        /// </param>
        /// <param name="outcomeSums">
        /// Array to be passed in to the method; it should have a length equal to the number of outcomes
        /// in the model.  The method adds the parameter values for each of the active outcomes in the
        /// predicate.
        /// </param>
        public virtual void GetPredicateData(string predicateLabel, int[] featureCounts, double[] outcomeSums)
        {
            if (mPredicates.ContainsKey(predicateLabel))
            {
                PatternedPredicate predicate = mPredicates[predicateLabel];
                int[] activeOutcomes         = mOutcomePatterns[predicate.OutcomePattern];

                for (int currentActiveOutcome = 1; currentActiveOutcome < activeOutcomes.Length; currentActiveOutcome++)
                {
                    int outcomeIndex = activeOutcomes[currentActiveOutcome];
                    featureCounts[outcomeIndex]++;
                    outcomeSums[outcomeIndex] += predicate.GetParameter(currentActiveOutcome - 1);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Returns model information for a predicate, given the predicate label.
        /// </summary>
        /// <param name="predicateLabel">
        /// The predicate label to fetch information for.
        /// </param>
        /// <param name="featureCounts">
        /// Array to be passed in to the method; it should have a length equal to the number of outcomes
        /// in the model.  The method increments the count of each outcome that is active in the specified
        /// predicate.
        /// </param>
        /// <param name="outcomeSums">
        /// Array to be passed in to the method; it should have a length equal to the number of outcomes
        /// in the model.  The method adds the parameter values for each of the active outcomes in the
        /// predicate.
        /// </param>
        public virtual void GetPredicateData(string predicateLabel, int[] featureCounts, double[] outcomeSums)
        {
            try
            {
                if (predicateLabel != null && _predicates.ContainsKey(predicateLabel))
                {
                    PatternedPredicate predicate = _predicates[predicateLabel];
                    int[] activeOutcomes         = _outcomePatterns[predicate.OutcomePattern];

                    for (int currentActiveOutcome = 1; currentActiveOutcome < activeOutcomes.Length; currentActiveOutcome++)
                    {
                        int outcomeIndex = activeOutcomes[currentActiveOutcome];
                        featureCounts[outcomeIndex]++;
                        outcomeSums[outcomeIndex] += predicate.GetParameter(currentActiveOutcome - 1);
                    }
                }
            }
            catch (ArgumentNullException ex)
            {
                throw new ArgumentException(string.Format("Try to find key '{0}' in predicates dictionary ({1} entries)", predicateLabel, _predicates.Count), ex);
            }
        }