예제 #1
0
        internal BayesianResult(BayesianClass <F> bc, double probability)
        {
            if (bc == null)
            {
                throw new ArgumentNullException(nameof(bc));
            }

            Class       = bc;
            Probability = probability;
        }
예제 #2
0
        /// <summary>
        /// Gets the bayesian class by the class name.
        /// </summary>
        /// <param name="name">The class name.</param>
        /// <param name="create">if set to <c>true</c> the class will be created if it cannot be found.</param>
        /// <returns>The <see cref="BayesianClass{F}"/> or a <c>null</c> value.</returns>
        protected BayesianClass <F> GetClass(string name, bool create)
        {
            foreach (var cls in Classes)
            {
                if (cls.Name == name)
                {
                    return(cls);
                }
            }

            if (!create)
            {
                return(null);
            }

            var bc = new BayesianClass <F>(name);

            Classes.Add(bc);
            return(bc);
        }