Beispiel #1
0
        public List<PredictionResult> DoStacking(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizeFormat = Normalize.OneMinusOne)
        {
            List<PredictionResult> classifiers = new List<PredictionResult>();
            //For each classifier run a crossvalidation and find the best params
            foreach (StdClassifier classifier in standardClassifiers)
            {
                List<PredictionResult> results = classifier.OldCrossValidate(feelingsmodel, 1, useIAPSratings, normalizeFormat);
                classifiers.Add(results.OrderBy(x => x.GetAverageFScore()).First());
            }

            List<List<double>> featureList = new List<List<double>>();
            //Create a List of list of answers from each machine
            for (int i = 0; i < samData.dataPoints.Count; i++)
            {
                List<double> featuresToDataPoint = new List<double>();
                foreach (PredictionResult classifier in classifiers)
                {
                    featuresToDataPoint.Add(classifier.guesses[i]);
                }
                featureList.Add(featuresToDataPoint);
            }
            //Split into nfold problems
            List<Tuple<SVMProblem, SVMProblem>> problems = featureList.GetCrossValidationSets<double>(samData, feelingsmodel, nFold, useIAPSratings);

            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();

            List<PredictionResult> finalResults = new List<PredictionResult>();

            //Run for each parameter setting
            int cnt = 1;
            foreach (SVMParameter SVMpara in Parameters)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(cnt++, Parameters.Count);
                }
                List<double> guesses = new List<double>();
                //model and predict each nfold
                foreach (Tuple<SVMProblem, SVMProblem> tupleProblem in problems)
                {
                    guesses.AddRange(tupleProblem.Item2.Predict(tupleProblem.Item1.Train(SVMpara)));
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, SVMpara, new List<Feature> { }, answers.ToList(), guesses.ConvertAll(x => (int)x));
                finalResults.Add(pR);
            }
            return finalResults;
        }
        public void ProcessNewLines()
        {
            /* arrange */
            var markdownBuilder = new StringBuilder();
            markdownBuilder.AppendLine("# content");
            markdownBuilder.Append("something here \n");
            markdownBuilder.Append("more more \r\n");

            var expectedMarkdown = new StringBuilder();
            expectedMarkdown.Append("# content\n");
            expectedMarkdown.Append("something here \n");
            expectedMarkdown.Append("more more \n");

            var normalize = new Normalize();
            /* act */
            var actual = normalize.Process(markdownBuilder.ToString());

            /* assert */
            actual.ShouldBeEquivalentTo(expectedMarkdown.ToString());
        }
Beispiel #3
0
        public PredictionResult DoBoosting(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizeFormat = Normalize.OneMinusOne)
        {
            if (boostingOrder.Count != standardClassifiers.Count)
            {
                //if boosting order and standardClassifier is not the same size an out of bounds is invetatible
                Log.LogMessage("The Boosting order list is not the same as the number of classifiers, I'm giving you a null");
                return null;
            }

            PredictionResult prevResult = null;
            for (int i = 0; i < boostingOrder.Count; i++)
            {
                if (i == 0)
                {
                    prevResult = FindBestFScorePrediction(standardClassifiers[boostingOrder[i]].CrossValidate(feelingsmodel, useIAPSratings, normalizeFormat));
                }
                else
                {
                    prevResult = FindBestFScorePrediction(standardClassifiers[boostingOrder[i]].CrossValidateWithBoosting(feelingsmodel, nFold, prevResult.guesses.ConvertAll(x => (double)x).ToArray(), useIAPSratings, normalizeFormat));
                }
            }
            return prevResult;
        }
Beispiel #4
0
 public override IEqualityComparer <MachineInstruction> CreateInstructionComparer(Normalize norm)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public double Angle(Vector2 vector)
 {
     return(Math.Acos(Normalize.DotProduct(vector.Normalize)));
 }
Beispiel #6
0
 public abstract IEqualityComparer <MachineInstruction> CreateInstructionComparer(Normalize norm);
 public VaxInstructionComparer(Normalize norm) : base(norm)
 {
 }
Beispiel #8
0
        public List<PredictionResult> CrossValidate(SAMDataPoint.FeelingModel feelingsmodel, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List<PredictionResult> predictedResults = new List<PredictionResult>();
            //Split into crossvalidation parts
            SVMProblem problems = GetFeatureValues(features, samData).NormalizeFeatureList<double>(normalizationType).CreateCompleteProblem(samData, feelingsmodel);

            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int progressCounter = 0;
            if (answers.Distinct().Count() <= 1)
            {
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(answers.ToList().ConvertAll(x => (double)x).ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, new SVMParameter(), features, answers.ToList(), answers.ToList().ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                Log.LogMessage(ONLY_ONE_CLASS);
                Log.LogMessage("");
                return predictedResults;
            }
            else if(problems.X.Count == 0)
            {
                Log.LogMessage("Empty problem in "+ Name);
                return null;
            }
            foreach (SVMParameter SVMpara in Parameters)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
                double[] guesses = new double[samData.dataPoints.Count];
                //model and predict each nfold
                try
                {
                    problems.CrossValidation(SVMpara, samData.dataPoints.Count, out guesses);
                }
                catch (Exception e)
                {
                    for (int i = 0; i < samData.dataPoints.Count; i++)
                    {
                        guesses[i] = -1;
                    }
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), Array.ConvertAll(guesses, (x=> (int)x)).ToList());
                predictedResults.Add(pR);
                progressCounter++;
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
            }

            return predictedResults;
        }
 public Msp430InstructionComparer(Normalize norm) : base(norm)
 {
 }
Beispiel #10
0
 public IEqualityComparer <MachineInstruction> CreateInstructionComparer(Normalize norm)
 {
     return(new Comp(norm));
 }
Beispiel #11
0
 public static float[][][] Erode(IOperand x)
 {
     float[][][] img = Bin(Normalize.ToFloat(((FormStandard)x).Image), x.ImageHeight, x.ImageWidth);
     return(Erode(img, ((FormStandard)x).Image.Height, ((FormStandard)x).Image.Width));
 }
Beispiel #12
0
 public X86InstructionComparer(Normalize norm)
     : base(norm)
 {
 }
Beispiel #13
0
 public Arm32InstructionComparer(Normalize norm) : base(norm)
 {
     this.norm = norm;
 }
Beispiel #14
0
 public override IEqualityComparer <MachineInstruction> CreateInstructionComparer(Normalize norm)
 => new PICInstructionComparer(norm);
 public IEqualityComparer<MachineInstruction> CreateInstructionComparer(Normalize norm)
 {
     return new X86InstructionComparer(norm);
 }
Beispiel #16
0
        public List<PredictionResult> CrossValidateWithBoosting(SAMDataPoint.FeelingModel feelingsmodel, int nFold, double[] answersFromPrevious, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List<PredictionResult> predictedResults = new List<PredictionResult>();

            List<List<double>> tempFeatuers = GetFeatureValues(features, samData);
            if (answersFromPrevious.Length != tempFeatuers.Count)
            {
                //answers from previous is not the same size as current feature list, e.g. something is wrong
                Log.LogMessage("The number of guessses from previous machine is the same as number of datapoints in this");
                return null;
            }
            //Split into crossvalidation parts
            List<List<double>> tempFeatures = tempFeatuers.NormalizeFeatureList<double>(normalizationType).ToList();
            for (int i = 0; i < tempFeatuers.Count; i++)
            {
                tempFeatuers[i].Add(answersFromPrevious[i]);
            }
            List<Tuple<SVMProblem, SVMProblem>> problems = tempFeatuers.GetCrossValidationSets<double>(samData, feelingsmodel, nFold, useIAPSratings);

            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();

            foreach (SVMParameter SVMpara in Parameters)
            {
                List<double> guesses = new List<double>();
                //model and predict each nfold
                foreach (Tuple<SVMProblem, SVMProblem> tupleProblem in problems)
                {
                    guesses.AddRange(tupleProblem.Item2.Predict(tupleProblem.Item1.Train(SVMpara)));
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), guesses.ConvertAll(x => (int)x).ToList());
                predictedResults.Add(pR);
            }
            return predictedResults;
        }
Beispiel #17
0
 public void CheckBadInputData()
 {
     // This used to trigger an exception in the underlying RegEx.
     Normalize.CleanupDeviceBrandName("${N", "${N.Foo");
 }
Beispiel #18
0
        public PredictionResult DoVoting(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizeFormat = Normalize.OneMinusOne)
        {
            List<PredictionResult> classifiers = new List<PredictionResult>();
            //For each classifier run a crossvalidation and find the best params
            int prg = 0;
            foreach (StdClassifier classifier in standardClassifiers)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(prg++, standardClassifiers.Count);
                }
                List<PredictionResult> results = classifier.OldCrossValidate(feelingsmodel, 1, useIAPSratings, normalizeFormat);
                classifiers.Add(results.OrderBy(x => x.GetAverageFScore()).First());
            }
            if (UpdateCallback != null)
            {
                UpdateCallback(standardClassifiers.Count, standardClassifiers.Count);
            }
            int labelCount = SAMData.GetNumberOfLabels(feelingsmodel);

            //Full List of indicies
            List<int> counter = new List<int>();
            for (int k = 0; k < samData.dataPoints.Count(); k++)
            {
                counter.Add(k);
            }
            //Divide indicies into correct nfold
            List<List<int>> trainIndicies = new List<List<int>>();
            List<List<int>> predictIndicies = new List<List<int>>();
            for (int i = 0; i < samData.dataPoints.Count(); i += nFold)
            {
                var temp = counter.Skip(i).Take(nFold).ToList();
                predictIndicies.Add(temp);
                trainIndicies.Add(counter.Except(temp).ToList());
            }

            List<Dictionary<int, double>> weightedGuesses = new List<Dictionary<int, double>>();
            //Fill up weightedGuesses List
            for (int nGuesses = 0; nGuesses < samData.dataPoints.Count; nGuesses++)
            {
                Dictionary<int, double> tempGuess = new Dictionary<int, double>();
                for (int indexClass = 0; indexClass < labelCount; indexClass++)
                {
                    tempGuess.Add(indexClass, 0);
                }
                weightedGuesses.Add(tempGuess);
            }

            //Split classifiers
            for (int i = 0; i < trainIndicies.Count; i++)
            {
                foreach (PredictionResult predictResult in classifiers)
                {
                    double correct = 0;
                    //calculate weights
                    for (int trainingIndex = 0; trainingIndex < trainIndicies[i].Count; trainingIndex++)
                    {
                        if (predictResult.guesses[trainIndicies[i][trainingIndex]] == samData.dataPoints[trainIndicies[i][trainingIndex]].ToAVCoordinate(feelingsmodel))
                        {
                            correct++;
                        }
                    }

                    //Add weight from the trainingset to each of the guesses
                    weightedGuesses[i][predictResult.guesses[i]] += (correct / trainIndicies.Count);
                }
            }

            //Calculate final answers
            List<double> guesses = new List<double>();

            foreach (Dictionary<int, double> answer in weightedGuesses)
            {
                int tempKey = -1;
                double tempMax = -1;
                foreach (int key in answer.Keys)
                {
                    if (answer[key] > tempMax)
                    {
                        tempKey = key;
                        tempMax = answer[key];
                    }
                }
                guesses.Add(tempKey);
            }

            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);

            //Calculate scoring results
            double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
            List<double> pres = CalculatePrecision(confus, numberOfLabels);
            List<double> recall = CalculateRecall(confus, numberOfLabels);
            List<double> fscore = CalculateFScore(pres, recall);
            return new PredictionResult(confus, recall, pres, fscore, new SVMParameter(), new List<Feature> { }, answers.ToList(), guesses.ConvertAll(x => (int)x));
        }
Beispiel #19
0
 public void CheckBrandOne()
 {
     Normalize.Brand("n").Should().Be("N");
     Normalize.Brand("N").Should().Be("N");
 }
 public virtual void Train(double[][] inputs, double[][] answers)
 {
     bpn.TrainNetwork(inputs, Normalize.FormAnswersBackPropagationPlast(answers), minError, learningRate, Momentum);
 }
Beispiel #21
0
 public InstructionComparer(Normalize norm)
 {
     this.norm = norm;
 }
Beispiel #22
0
 public Bitmap GetBitmap()
 {
     return(Normalize.FromFloat(Image));
 }
Beispiel #23
0
        static void Main(string[] args)
        {
            /* DataSet ds = new DataSet();
             * DataSet ds2 = new DataSet();
             * DataTable dt = new DataTable();
             * DataTable dt2 = new DataTable();
             * Stopwatch sWatch = new Stopwatch();
             * TimeSpan tSpan;
             *
             *
             * try
             * {
             *   //  під'єднання до бд
             *   string connstring = "Server=127.0.0.1;Port=5432;User Id=postgres;Password=1postgres;Database=Labs;";
             *   NpgsqlConnection conn = new NpgsqlConnection(connstring);
             *   conn.Open();
             *   string sql = "SELECT * FROM Task1 ORDER BY id";
             *   //string sql1 = "SELECT DISTINCT Type FROM train ORDER BY Type";
             *   NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);
             *   ds.Reset();
             *   da.Fill(ds);
             *   dt = ds.Tables[0];
             *
             *   /* da = new NpgsqlDataAdapter(sql1, conn);
             *    da.Fill(ds2);
             *    dt2 = ds2.Tables[0];*/
            /*   conn.Close();
             * }
             * catch (Exception msg)
             * {
             * Console.WriteLine(msg.ToString());
             * throw;
             * }
             *
             * foreach (DataColumn dt3 in dt.Columns)
             * {
             * Console.WriteLine(dt3.ColumnName);
             * }
             *
             * int TRAINING_PATTERNS = dt.Columns.Count - 1;
             * int PARAMETERS = dt.Rows.Count;
             * //int NUM_OF_CLUSTERS = dt2.Rows.Count;
             * //Console.WriteLine("Number of clusters = {0}", NUM_OF_CLUSTERS);
             * double MIN_ERROR = 0.001;
             * int TestAmount = 6;
             *
             * // Параметри для BackPropagation мережі
             * int[] layerSizes = new int[3] { 2, 7, 1 }; // кількість шарів та нейронів у шарах
             *
             * // активаційні функції для кожного шару
             * TransferFunction[] TFuncs = new TransferFunction[3] {TransferFunction.None,
             *                                                TransferFunction.Sigmoid,
             *                                                TransferFunction.Sigmoid};
             * double LEARNING_RATE1 = 0.15; // швидкість навчання
             * double MOMENTUM = 0.1; // крефіцієнт для навчання
             *
             * // Параметри для LVQ мережі
             * double LEARNING_RATE2 = 1.0; // швидкість навчання
             * double DECAY_RATE = 0.7; // швидкість зміни швидкості нвчання
             *
             * double[] h = new double[TRAINING_PATTERNS]; // критерій Ст'юдента
             *
             *
             * double[][] inputs = new double[TRAINING_PATTERNS][];
             * double[][] answers = new double[TRAINING_PATTERNS][];
             *
             * for (int i = 0; i < TRAINING_PATTERNS; i++)
             * {
             * inputs[i] = new double[PARAMETERS];
             * answers[i] = new double[1];
             * }
             *
             *
             *
             * // зчитування параметрів
             * for (int i = 0; i < TRAINING_PATTERNS; i++)
             * {
             * for (int k = 0; k < dt.Rows.Count; k++)
             *     inputs[i][k] = Convert.ToDouble(dt.Rows[k][i + 1]);
             *
             * //answers[i][0] = Convert.ToDouble(dt.Rows[i][dt.Columns.Count - 1]);
             * }
             *
             * Console.WriteLine("Training Patterns:");
             * for (int i = 0; i < TRAINING_PATTERNS; i++)
             * {
             * for (int p = 0; p < PARAMETERS; p++)
             *     Console.Write(inputs[i][p] + " ");
             * Console.WriteLine();
             * Console.WriteLine();
             * }
             *
             * /* for (int i = 0; i < inputs.GetUpperBound(0) + 1; i++)
             * {
             *  h[i] = Statistic.Interval(inputs[i]);
             * }
             *
             * Console.WriteLine("Student parameters:");
             * foreach(double param in h)
             *  Console.WriteLine("param = {0}", param);
             *
             * // Масив частот
             * Dictionary<double, int>[] pairs = new Dictionary<double, int>[TRAINING_PATTERNS];
             * for (int i = 0; i < TRAINING_PATTERNS; i++)
             * {
             *  pairs[i] = new Dictionary<double, int>();
             * }
             * Console.WriteLine("Amount of pairs: {0}", pairs.Count());
             * //ArrayList array = new ArrayList();
             * for (int i = 0; i < TRAINING_PATTERNS; i++) {
             *  for (double curr = inputs[i].Min(); curr <= inputs[i].Max(); curr += h[i])
             *  {
             *      int count = 0;
             *      for (int j = 0; j < inputs[i].Length; j++)
             *      {
             *          if (curr <= inputs[i][j] && inputs[i][j] < curr + h[i])
             *              count++;
             *      }
             *      pairs[i].Add((curr + h[i] + curr)/2.0, count);
             *      Console.WriteLine("Key = {0}, Value = {1}", pairs[i].Last().Key, pairs[i].Last().Value);
             *  }
             *
             *  Console.WriteLine();
             * }*/

            /* double[][] array2 = Statistic.CreateArrayFromDictionary(inputs);
             * for (int i = 0; i < array2.GetUpperBound(0) + 1; i++)
             * {
             *   for (int j = 0; j < array2[i].Length; j++)
             *       Console.Write(array2[i][j] + " ");
             *   Console.WriteLine();
             * }*/



            /* Normalize.NormalizeParameters(inputs);
             *
             * BackPropagationNetwork bpn = new BackPropagationNetwork(layerSizes, TFuncs);
             *
             * double[] output = new double[1];
             *
             * sWatch.Start();
             * bpn.TrainNetwork(inputs, Normalize.FormAnswersBackPropagation(answers), MIN_ERROR, LEARNING_RATE1, MOMENTUM);
             * sWatch.Stop();
             *
             * tSpan = sWatch.Elapsed;
             * Console.WriteLine("Time for BackPropagation " + tSpan.ToString()); // Виведення часу навчання
             *
             * sWatch.Reset(); // обнуляємо час
             *
             * bpn.Save(@"d:\Навчання\test_network.xml");
             */

            // тестова вибірка
            double[][] trainPatterns = new double[][] {
                new double[] { 0.189, 0.1, 0.86, 0.22 },
                new double[] { 0.141, 0.078, 0.123, 0.12, },
                new double[] { 0.15, 0.095, 0.128, 0.08 },
                new double[] { 0.126, 0.401, 0.085, 0.04 },
                new double[] { 0.109, 0.156, 0.179, 0.08 },
                new double[] { 0.095, 0.278, 0.124, 0.05 },
                new double[] { 0.156, 0.124, 0.09, 0.17 },
                new double[] { 0.178, 0.167, 0.075, 0.05 },
                new double[] { 0.107, 0.222, 0.119, 0.14 },
                new double[] { 0.115, 0.174, 0.182, 0.07 },
                new double[] { 0.126, 0.151, 0.144, 0.1 },
                new double[] { 0.088, 0.189, 0.25, 0.03 },
                new double[] { 0.12, 0.335, 0.086, 0.03 },
                new double[] { 0.09, 0.147, 0.197, 0.07 },
                new double[] { 0.085, 0.15, 0.224, 0.04 }
            };

            double[][] answers = new double[][]
            {
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 2 },
                new double[] { 2 },
                new double[] { 2 },
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 1 },
                new double[] { 2 },
                new double[] { 2 },
                new double[] { 2 },
                new double[] { 2 }
            };
            // Параметри для DeltaBarDelta мережі
            int[] layerSizes = new int[3] {
                4, 8, 1
            };                                         // кількість шарів та нейронів у шарах

            // активаційні функції для кожного шару
            TransferFunction[] TFuncs = new TransferFunction[3] {
                TransferFunction.None,
                TransferFunction.Sigmoid,
                TransferFunction.Sigmoid
            };
            double LEARNING_RATE1 = 0.5; // швидкість навчання
            double MOMENTUM       = 0.1; // крефіцієнт для навчання

            double[]      output = new double[] { };
            DeltaBarDelta dbd1   = new DeltaBarDelta(layerSizes, TFuncs, LEARNING_RATE1);

            Console.WriteLine("start");

            dbd1.TrainNetwork(trainPatterns, Normalize.FormAnswersDeltaBarDelta(answers), 0.001, 0.01, 0.05, 0.05, MOMENTUM);
            Console.WriteLine("finish");
            for (int i = 0; i < trainPatterns.GetUpperBound(0) + 1; i++)
            {
                Console.WriteLine("The result for vector {0} : Cluster {1}", i, dbd1.getCluster(trainPatterns[i], output));
            }



            /*DeltaBarDelta bpn2 = new DeltaBarDelta(@"d:\test backpropagation network.xml", 1);
             * string network = bpn2.Save();
             * DeltaBarDelta bpn3 = new DeltaBarDelta(network);
             * string network3 = bpn3.Save();
             * Console.WriteLine(network3);*/
            /*  double[] input123 = new double[] { 0.854, 0.079, 0.05, 0.023, 0.002 };
             * double[] output123 = new double[1];
             * Console.WriteLine("My answer is " + bpn2.getCluster(input123, output123));*/
            /*for (int k = 0; k < TRAINING_PATTERNS; k++)
             * {
             *  Console.WriteLine("cluster {0:0.000}", bpn2.getCluster(inputs[k], output));
             * }
             *
             * double[][] testArray = GenerateTest.GenerateOutputICG(PARAMETERS, TestAmount);
             * Normalize.NormalizeTest(testArray);
             *
             * for (int k = 0; k < TestAmount; k++)
             * {
             *  Console.WriteLine("---- cluster {0:}", bpn2.getCluster(testArray[k], output));
             * }
             *
             * sWatch.Start();
             * LVQ lvq = new LVQ(inputs, Normalize.FormAnswersLVQ(answers), 0.0000000001, LEARNING_RATE2, DECAY_RATE, NUM_OF_CLUSTERS);
             * lvq.TrainNetwork();
             * sWatch.Stop();
             *
             * tSpan = sWatch.Elapsed;
             *
             * Console.WriteLine("Time for LVQ " + tSpan.ToString());
             *
             * for(int i = 0; i < TRAINING_PATTERNS; i++)
             * {
             *   Console.WriteLine("The result for vector {0} : Cluster {1}", i, lvq.getCluster(inputs[i]));
             * }
             *
             * for (int i = 0; i < TestAmount; i++)
             * {
             *  Console.WriteLine("---- The result for vector2 {0} : Cluster {1}", i, lvq.getCluster(testArray[i]));
             * }
             *
             * lvq.Save(@"d:\Навчання\test_network2.xml");
             *
             * LVQ lvq2 = new LVQ(@"d:\Навчання\test_network2.xml");
             *
             * for (int i = 0; i < TestAmount; i++)
             * {
             *  Console.WriteLine("---- The result for vector2 {0} : Cluster {1}", i, lvq2.getCluster(testArray[i]));
             * }
             */
            Console.ReadKey();
        }
Beispiel #24
0
 public override IEqualityComparer <MachineInstruction> CreateInstructionComparer(Normalize norm)
 {
     return(new RiscVInstructionComparer(norm));
 }
Beispiel #25
0
 public override IEqualityComparer<MachineInstruction>? CreateInstructionComparer(Normalize norm)
 {
     return null;
 }
Beispiel #26
0
 public PowerPcInstructionComparer(Normalize norm) : base(norm)
 {
     this.norm = norm;
 }
Beispiel #27
0
 public Pdp11InstructionComparer(Normalize norm) : base(norm)
 {
 }
Beispiel #28
0
        public Bitmap Equalizar(Imagem img)
        {
            Imagem resultadoImagem = new Imagem(img.width, img.height, img.maxVal, (int[][])img.pixels.Clone());

            _frequenciaInicial = new Dictionary <int, int>();
            _frequenciaFinal   = new Dictionary <int, int>();

            Dictionary <int, List <double> > frequencia = new Dictionary <int, List <double> >();

            for (int i = 0; i < resultadoImagem.width; i++)
            {
                for (int j = 0; j < resultadoImagem.height; j++)
                {
                    int valor = img.pixels[i][j];
                    if (frequencia.Keys.Contains(valor))
                    {
                        frequencia[valor][0]++;
                        _frequenciaInicial[valor]++;
                    }
                    else
                    {
                        List <double> lista = new List <double>();
                        lista.Add(1);
                        frequencia.Add(valor, lista);
                        _frequenciaInicial.Add(valor, 1);
                    }
                }
            }

            foreach (var item in frequencia.OrderBy(k => k.Key))
            {
                //Calcula a frequencia
                frequencia[item.Key].Add(frequencia[item.Key][0] / (double)(img.height * img.width));
                frequencia[item.Key].Add(frequencia[item.Key][1]);
                if (item.Key != 0)
                {
                    frequencia[item.Key][2] += (frequencia[item.Key - 1][2]);
                }
            }

            Dictionary <int, int> escalaCinza = new Dictionary <int, int>();

            foreach (var item in frequencia.OrderBy(k => k.Key))
            {
                int novoValor = Convert.ToInt32(item.Value[2] * (img.maxVal - 1));
                escalaCinza.Add(Convert.ToInt32(item.Key), novoValor);
            }

            for (int i = 0; i < img.width; i++)
            {
                for (int j = 0; j < img.height; j++)
                {
                    int antigoValor = resultadoImagem.pixels[i][j];
                    resultadoImagem.pixels[i][j] = escalaCinza[antigoValor];
                }
            }

            for (int i = 0; i < resultadoImagem.width; i++)
            {
                for (int j = 0; j < resultadoImagem.height; j++)
                {
                    int valor = resultadoImagem.pixels[i][j];
                    if (_frequenciaFinal.Keys.Contains(valor))
                    {
                        _frequenciaFinal[valor]++;
                    }
                    else
                    {
                        _frequenciaFinal.Add(valor, 1);
                    }
                }
            }
            //Para poder atualizar os atributos maximo e mínimo da imagem.
            resultadoImagem = new Imagem(img.width, img.height, img.maxVal, (int[][])resultadoImagem.pixels.Clone());

            LeitorImagem leitor = new LeitorImagem(Normalize.NormalizeImage(resultadoImagem));

            return(leitor.ConverterParaBitmap());
        }
Beispiel #29
0
 public Comp(Normalize norm)
 {
     this.norm = norm;
 }
        public static string GetArtistDirectoryName(Track track, string trackTitleSeparator = " ", int maxLength = -1)
        {
            var artistDir = Normalize.RemoveDiacritics(track.Artists);

            return(GetCleanFileFolder(artistDir, maxLength: maxLength).Replace(" ", trackTitleSeparator));
        }
Beispiel #31
0
        /// <summary>
        /// Run crossvalidation for the feature setup for this machine
        /// </summary>
        /// <param name="feelingsmodel"></param>
        /// <param name="nFold"></param>
        /// <param name="useIAPSratings"></param>
        public List <PredictionResult> OldCrossValidate(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List <PredictionResult> predictedResults = new List <PredictionResult>();
            //Split into crossvalidation parts
            List <Tuple <SVMProblem, SVMProblem> > problems = GetFeatureValues(features, samData).NormalizeFeatureList <double>(normalizationType).GetCrossValidationSets <double>(samData, feelingsmodel, nFold, useIAPSratings);

            //Get correct results
            int[] answers             = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int   progressCounter     = 0;
            bool  postedOneClassError = false;

            if (answers.Distinct().Count() <= 1)
            {
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(answers.ToList().ConvertAll(x => (double)x).ToArray(), answers, numberOfLabels);
                List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                List <double>    recall = CalculateRecall(confus, numberOfLabels);
                List <double>    fscore = CalculateFScore(pres, recall);
                PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, new SVMParameter(), features, answers.ToList(), answers.ToList().ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                Log.LogMessage(ONLY_ONE_CLASS);
                Log.LogMessage("");
                return(predictedResults);
            }
            foreach (SVMParameter SVMpara in Parameters)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
                List <double> guesses = new List <double>();
                //model and predict each nfold
                try
                {
                    foreach (Tuple <SVMProblem, SVMProblem> tupleProblem in problems)
                    {
                        SVMModel trainingModel = tupleProblem.Item1.Train(SVMpara);
                        if (trainingModel.ClassCount <= 1)
                        {
                            if (!postedOneClassError)
                            {
                                Log.LogMessage(ONLY_ONE_CLASS_IN_TRAINING);
                                postedOneClassError = true;
                            }
                            guesses.AddRange(tupleProblem.Item1.Y.ToList().Take(tupleProblem.Item2.Y.Count()).ToList());
                        }
                        else
                        {
                            double[] d = tupleProblem.Item2.Predict(trainingModel);
                            guesses.AddRange(d);
                        }
                    }
                }
                catch (Exception e)
                {
                    for (int i = 0; i < samData.dataPoints.Count; i++)
                    {
                        guesses.Add(-1);
                    }
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                List <double>    recall = CalculateRecall(confus, numberOfLabels);
                List <double>    fscore = CalculateFScore(pres, recall);
                PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), guesses.ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
            }

            return(predictedResults);
        }
Beispiel #32
0
        /// <summary>
        /// Run crossvalidation for each combination of the features for this machine
        /// </summary>
        /// <param name="feelingsmodel"></param>
        /// <param name="nFold"></param>
        /// <param name="useIAPSratings"></param>
        public List<PredictionResult> CrossValidateCombinations(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List<List<bool>> combinations = CalculateCombinations(new List<bool>() { }, features.Count);

            //Get different combination of problems
            List<Tuple<List<Tuple<SVMProblem, SVMProblem>>, List<Feature>>> featureCombinationProblems = new List<Tuple<List<Tuple<SVMProblem, SVMProblem>>, List<Feature>>>();

            for (int i = 0; i < combinations.Count; i++)
            {
                List<Feature> tempFeatures = new List<Feature>();
                for (int j = 0; j < combinations[i].Count; j++)
                {
                    // For each feature combination save the different problems for crossvalidation

                    if (combinations[i][j] == true)
                    {
                        tempFeatures.Add(features[j]);
                    }

                }
                featureCombinationProblems.Add
                                        (
                                            new Tuple<List<Tuple<SVMProblem, SVMProblem>>, List<Feature>>
                                            (
                                                GetFeatureValues(tempFeatures, samData).NormalizeFeatureList<double>(normalizationType).GetCrossValidationSets<double>(samData, feelingsmodel, nFold, useIAPSratings),
                                                tempFeatures
                                            )
                                         );
            }

            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int progressCounter = 0;
            List<PredictionResult> predictionResults = new List<PredictionResult>();
            foreach (SVMParameter SVMpara in Parameters)
            {
                //For each feature setup
                for (int n = 0; n < featureCombinationProblems.Count; n++)
                {
                    if (UpdateCallback != null)
                    {
                        UpdateCallback(progressCounter, Parameters.Count * featureCombinationProblems.Count);
                    }
                    //PrintProgress(progressCounter, featureCombinationProblems.Count);
                    List<double> guesses = new List<double>();
                    //model and predict each nfold
                    foreach (var tupleProblem in featureCombinationProblems[n].Item1)
                    {
                        guesses.AddRange(tupleProblem.Item2.Predict(tupleProblem.Item1.Train(SVMpara)));
                    }
                    int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                    //Calculate scoring results
                    double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                    List<double> pres = CalculatePrecision(confus, numberOfLabels);
                    List<double> recall = CalculateRecall(confus, numberOfLabels);
                    List<double> fscore = CalculateFScore(pres, recall);
                    PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, SVMpara, featureCombinationProblems[n].Item2, answers.ToList(), guesses.ConvertAll(x => (int)x));
                    predictionResults.Add(pR);
                    progressCounter++;
                }

            }
            if (UpdateCallback != null)
            {
                UpdateCallback(progressCounter, Parameters.Count * featureCombinationProblems.Count);
            }

            return predictionResults;
        }
Beispiel #33
0
        public List <PredictionResult> CrossValidate(SAMDataPoint.FeelingModel feelingsmodel, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List <PredictionResult> predictedResults = new List <PredictionResult>();
            //Split into crossvalidation parts
            SVMProblem problems = GetFeatureValues(features, samData).NormalizeFeatureList <double>(normalizationType).CreateCompleteProblem(samData, feelingsmodel);

            //Get correct results
            int[] answers         = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int   progressCounter = 0;

            if (answers.Distinct().Count() <= 1)
            {
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(answers.ToList().ConvertAll(x => (double)x).ToArray(), answers, numberOfLabels);
                List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                List <double>    recall = CalculateRecall(confus, numberOfLabels);
                List <double>    fscore = CalculateFScore(pres, recall);
                PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, new SVMParameter(), features, answers.ToList(), answers.ToList().ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                Log.LogMessage(ONLY_ONE_CLASS);
                Log.LogMessage("");
                return(predictedResults);
            }
            else if (problems.X.Count == 0)
            {
                Log.LogMessage("Empty problem in " + Name);
                return(null);
            }
            foreach (SVMParameter SVMpara in Parameters)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
                double[] guesses = new double[samData.dataPoints.Count];
                //model and predict each nfold
                try
                {
                    problems.CrossValidation(SVMpara, samData.dataPoints.Count, out guesses);
                }
                catch (Exception e)
                {
                    for (int i = 0; i < samData.dataPoints.Count; i++)
                    {
                        guesses[i] = -1;
                    }
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                List <double>    recall = CalculateRecall(confus, numberOfLabels);
                List <double>    fscore = CalculateFScore(pres, recall);
                PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), Array.ConvertAll(guesses, (x => (int)x)).ToList());
                predictedResults.Add(pR);
                progressCounter++;
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
            }

            return(predictedResults);
        }
Beispiel #34
0
        /// <summary>
        /// Run crossvalidation for the feature setup for this machine
        /// </summary>
        /// <param name="feelingsmodel"></param>
        /// <param name="nFold"></param>
        /// <param name="useIAPSratings"></param>
        public List<PredictionResult> OldCrossValidate(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List<PredictionResult> predictedResults = new List<PredictionResult>();
            //Split into crossvalidation parts
            List<Tuple<SVMProblem, SVMProblem>> problems = GetFeatureValues(features, samData).NormalizeFeatureList<double>(normalizationType).GetCrossValidationSets<double>(samData, feelingsmodel, nFold, useIAPSratings);
            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int progressCounter = 0;
            bool postedOneClassError = false;
            if(answers.Distinct().Count() <= 1)
            {
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(answers.ToList().ConvertAll(x=>(double)x).ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, new SVMParameter(), features, answers.ToList(), answers.ToList().ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                Log.LogMessage(ONLY_ONE_CLASS);
                Log.LogMessage("");
                return predictedResults;
            }
            foreach (SVMParameter SVMpara in Parameters)
            {
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
                List<double> guesses = new List<double>();
                //model and predict each nfold
                try
                {
                    foreach (Tuple<SVMProblem, SVMProblem> tupleProblem in problems)
                    {
                        SVMModel trainingModel = tupleProblem.Item1.Train(SVMpara);
                        if (trainingModel.ClassCount <= 1)
                        {
                            if (!postedOneClassError)
                            {
                                Log.LogMessage(ONLY_ONE_CLASS_IN_TRAINING);
                                postedOneClassError = true;
                            }
                            guesses.AddRange(tupleProblem.Item1.Y.ToList().Take(tupleProblem.Item2.Y.Count()).ToList());
                        }
                        else
                        {
                            double[] d = tupleProblem.Item2.Predict(trainingModel);
                            guesses.AddRange(d);
                        }
                    }
                }
                catch(Exception e)
                {
                    for (int i = 0; i < samData.dataPoints.Count; i++)
                    {
                        guesses.Add(-1);
                    }
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List<double> pres = CalculatePrecision(confus, numberOfLabels);
                List<double> recall = CalculateRecall(confus, numberOfLabels);
                List<double> fscore = CalculateFScore(pres, recall);
                PredictionResult pR = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), guesses.ConvertAll(x => (int)x));
                predictedResults.Add(pR);
                progressCounter++;
                if (UpdateCallback != null)
                {
                    UpdateCallback(progressCounter, Parameters.Count);
                }
            }

            return predictedResults;
        }
Beispiel #35
0
        public List <PredictionResult> CrossValidateWithBoosting(SAMDataPoint.FeelingModel feelingsmodel, int nFold, double[] answersFromPrevious, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List <PredictionResult> predictedResults = new List <PredictionResult>();

            List <List <double> > tempFeatuers = GetFeatureValues(features, samData);

            if (answersFromPrevious.Length != tempFeatuers.Count)
            {
                //answers from previous is not the same size as current feature list, e.g. something is wrong
                Log.LogMessage("The number of guessses from previous machine is the same as number of datapoints in this");
                return(null);
            }
            //Split into crossvalidation parts
            List <List <double> > tempFeatures = tempFeatuers.NormalizeFeatureList <double>(normalizationType).ToList();

            for (int i = 0; i < tempFeatuers.Count; i++)
            {
                tempFeatuers[i].Add(answersFromPrevious[i]);
            }
            List <Tuple <SVMProblem, SVMProblem> > problems = tempFeatuers.GetCrossValidationSets <double>(samData, feelingsmodel, nFold, useIAPSratings);


            //Get correct results
            int[] answers = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();

            foreach (SVMParameter SVMpara in Parameters)
            {
                List <double> guesses = new List <double>();
                //model and predict each nfold
                foreach (Tuple <SVMProblem, SVMProblem> tupleProblem in problems)
                {
                    guesses.AddRange(tupleProblem.Item2.Predict(tupleProblem.Item1.Train(SVMpara)));
                }
                int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                //Calculate scoring results
                double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                List <double>    recall = CalculateRecall(confus, numberOfLabels);
                List <double>    fscore = CalculateFScore(pres, recall);
                PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, SVMpara, features, answers.ToList(), guesses.ConvertAll(x => (int)x).ToList());
                predictedResults.Add(pR);
            }
            return(predictedResults);
        }
Beispiel #36
0
 public abstract IEqualityComparer<MachineInstruction> CreateInstructionComparer(Normalize norm);
Beispiel #37
0
        /// <summary>
        /// Run crossvalidation for each combination of the features for this machine
        /// </summary>
        /// <param name="feelingsmodel"></param>
        /// <param name="nFold"></param>
        /// <param name="useIAPSratings"></param>
        public List <PredictionResult> CrossValidateCombinations(SAMDataPoint.FeelingModel feelingsmodel, int nFold, bool useIAPSratings = false, Normalize normalizationType = Normalize.OneMinusOne)
        {
            List <List <bool> > combinations = CalculateCombinations(new List <bool>()
            {
            }, features.Count);

            //Get different combination of problems
            List <Tuple <List <Tuple <SVMProblem, SVMProblem> >, List <Feature> > > featureCombinationProblems = new List <Tuple <List <Tuple <SVMProblem, SVMProblem> >, List <Feature> > >();

            for (int i = 0; i < combinations.Count; i++)
            {
                List <Feature> tempFeatures = new List <Feature>();
                for (int j = 0; j < combinations[i].Count; j++)
                {
                    // For each feature combination save the different problems for crossvalidation

                    if (combinations[i][j] == true)
                    {
                        tempFeatures.Add(features[j]);
                    }
                }
                featureCombinationProblems.Add
                (
                    new Tuple <List <Tuple <SVMProblem, SVMProblem> >, List <Feature> >
                    (
                        GetFeatureValues(tempFeatures, samData).NormalizeFeatureList <double>(normalizationType).GetCrossValidationSets <double>(samData, feelingsmodel, nFold, useIAPSratings),
                        tempFeatures
                    )
                );
            }

            //Get correct results
            int[] answers         = samData.dataPoints.Select(x => x.ToAVCoordinate(feelingsmodel, useIAPSratings)).ToArray();
            int   progressCounter = 0;
            List <PredictionResult> predictionResults = new List <PredictionResult>();

            foreach (SVMParameter SVMpara in Parameters)
            {
                //For each feature setup
                for (int n = 0; n < featureCombinationProblems.Count; n++)
                {
                    if (UpdateCallback != null)
                    {
                        UpdateCallback(progressCounter, Parameters.Count * featureCombinationProblems.Count);
                    }
                    //PrintProgress(progressCounter, featureCombinationProblems.Count);
                    List <double> guesses = new List <double>();
                    //model and predict each nfold
                    foreach (var tupleProblem in featureCombinationProblems[n].Item1)
                    {
                        guesses.AddRange(tupleProblem.Item2.Predict(tupleProblem.Item1.Train(SVMpara)));
                    }
                    int numberOfLabels = SAMData.GetNumberOfLabels(feelingsmodel);
                    //Calculate scoring results
                    double[,] confus = CalculateConfusion(guesses.ToArray(), answers, numberOfLabels);
                    List <double>    pres   = CalculatePrecision(confus, numberOfLabels);
                    List <double>    recall = CalculateRecall(confus, numberOfLabels);
                    List <double>    fscore = CalculateFScore(pres, recall);
                    PredictionResult pR     = new PredictionResult(confus, recall, pres, fscore, SVMpara, featureCombinationProblems[n].Item2, answers.ToList(), guesses.ConvertAll(x => (int)x));
                    predictionResults.Add(pR);
                    progressCounter++;
                }
            }
            if (UpdateCallback != null)
            {
                UpdateCallback(progressCounter, Parameters.Count * featureCombinationProblems.Count);
            }

            return(predictionResults);
        }
 public RiscVInstructionComparer(Normalize norm) : base(norm)
 {
 }
Beispiel #39
0
 public Tlcs900InstructionComparer(Normalize norm) : base(norm)
 {
     this.norm = norm;
 }
Beispiel #40
0
 public override IEqualityComparer<MachineInstruction> CreateInstructionComparer(Normalize norm)
 {
     throw new NotImplementedException();
 }
Beispiel #41
0
 public Draw()
 {
     this.normalize = new Normalize();
     this.bitmap    = new Bitmap(normalize.environment.Width, normalize.environment.Height);
 }