Example #1
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            Example example = null;

            double[] errors = new double[dataset.Size];

            for (int i = 0; i < dataset.Size; i++)
            {
                example = dataset[i];

                int actual = example.Label;

                Prediction prediction  = classifier.Classify(example);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                errors[i] = Math.Abs(1 - prediction.Probabilities[actual]);
            }

            Array.Sort(errors);

            double MedAE = errors[errors.Length / 2];

            return(MedAE);
        }
Example #2
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            double MAE = 0;

            Example example = null;

            for (int i = 0; i < dataset.Size; i++)
            {
                example = dataset[i];

                int actual = example.Label;

                Prediction prediction  = classifier.Classify(example);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                MAE += Math.Abs(1 - prediction.Probabilities[actual]);
            }

            MAE = MAE / dataset.Size;

            return(MAE);
        }
Example #3
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            double QLE = 0;

            Example example = null;

            for (int i = 0; i < dataset.Size; i++)
            {
                example = dataset[i];

                int actual = example.Label;

                Prediction prediction  = classifier.Classify(example);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                QLE += Math.Log(1 + Math.Exp(-probability));
            }

            QLE = QLE / dataset.Size;

            return(QLE);
        }
Example #4
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            double MSE = 0;

            Instance instance = null;

            for (int i = 0; i < dataset.Size; i++)
            {
                instance = dataset[i];

                int actual = instance.Label;

                Prediction prediction  = classifier.Classify(instance);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                MSE += Math.Pow(1 - prediction.Probabilities[actual], 2);
            }

            MSE = Math.Sqrt(MSE) / dataset.Size;

            return(MSE);
        }
Example #5
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            double QLF = 0;

            Example example = null;

            for (int i = 0; i < dataset.Size; i++)
            {
                example = dataset[i];

                int actual = example.Label;

                Prediction prediction  = classifier.Classify(example);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                double value = 0;

                for (int index = 0; index < dataset.Metadata.Target.Length; index++)
                {
                    if (index == actual)
                    {
                        value -= 2 * probability;
                    }
                    else
                    {
                        value += Math.Pow(prediction.Probabilities[index], 2);
                    }
                }

                QLF += (2 + value) / 3;
            }

            QLF = QLF / dataset.Size;

            return(QLF);
        }
Example #6
0
        public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
        {
            double BIReward = 0;

            double[] classProbabilities = new double[dataset.Metadata.Target.Length];

            for (int i = 0; i < classProbabilities.Length; i++)
            {
                classProbabilities[i] = (double)dataset.Filter(i).Count / (double)dataset.Size;
            }

            Example example = null;

            for (int i = 0; i < dataset.Size; i++)
            {
                example = dataset[i];

                int actual = example.Label;

                Prediction prediction  = classifier.Classify(example);
                int        predicted   = prediction.Label;
                double     probability = prediction.Probabilities[prediction.Label];

                if (predicted == actual)
                {
                    BIReward += Math.Log(probability / classProbabilities[actual]);
                }
                else
                {
                    BIReward += Math.Log((1 - probability) / (1 - classProbabilities[actual]));
                }
            }

            BIReward = (BIReward / dataset.Size) + 0.5;

            return(BIReward);
        }