示例#1
0
        public bool Classify(List <IdNumber> idNumbersList, ClassProbabilty classProbabilty, List <ProbabilityOfFeatureValue> probabilityOfFeatureValues)
        {
            var pP = 1.00;
            var pN = 1.00;
            var pX = 1.00;

            foreach (var item in idNumbersList)
            {
                var result = probabilityOfFeatureValues.Where(p => p.FeatureId == item.Id && p.PropertyValue.Equals(item.Number)).FirstOrDefault();
                if (result != null)
                {
                    pP *= result.PositiveProbability;
                    pN *= result.NegativeProbability;
                    pX *= result.AllProbability;
                }
            }
            var pPResult = pP / pX;
            var pNResult = pN / pX;

            if (pPResult > pNResult)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public List <bool> ClassifyAllTable(List <List <double> > dataSet, ClassProbabilty classProbabilty, List <ProbabilityOfFeatureValue> probabilityOfFeatureValues)
        {
            List <bool> classifyResult = new List <bool>();

            for (int i = 0; i < dataSet[0].Count; i++)
            {
                List <IdNumber> idNumbersList = new List <IdNumber>();
                for (int j = 0; j < dataSet.Count; j++)
                {
                    idNumbersList.Add(new IdNumber(j, dataSet[j][i]));
                }
                classifyResult.Add(Classify(idNumbersList, classProbabilty, probabilityOfFeatureValues));
                Console.WriteLine($"numer klasyfikacji: {i}");
            }
            return(classifyResult);
        }
示例#3
0
        public List <bool> ClassifyTableWithSelectedFeatures(List <List <double> > dataSet, ClassProbabilty classProbabilty, List <ProbabilityOfFeatureValue> probabilityOfFeatureValues, List <IdNumber> selectedFeaturesWithCorrelation)
        {
            List <bool> classifyResult = new List <bool>();

            for (int i = 0; i < dataSet[0].Count; i++)
            {
                List <IdNumber> idNumbersList = new List <IdNumber>();
                foreach (var item in selectedFeaturesWithCorrelation)
                {
                    idNumbersList.Add(new IdNumber(item.Id, dataSet[item.Id][i]));
                }
                classifyResult.Add(Classify(idNumbersList, classProbabilty, probabilityOfFeatureValues));
                Console.WriteLine($"numer klasyfikacji: {i}");
            }
            return(classifyResult);
        }