Ejemplo n.º 1
0
        /// <summary>
        /// Returns trained 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 void GetPredicateData(string predicateLabel, int[] featureCounts, double[] outcomeSums)
        {
            PatternedPredicate predicate = (PatternedPredicate)mPredicates[predicateLabel];

            if (predicate != null)
            {
                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);
                }
            }
        }