private SymbolicNearestNeighbourClassificationModel(SymbolicNearestNeighbourClassificationModel original, Cloner cloner)
     : base(original, cloner)
 {
     k = original.k;
     frequencyComparer      = new ClassFrequencyComparer(original.frequencyComparer);
     trainedEstimatedValues = new List <double>(original.trainedEstimatedValues);
     trainedClasses         = new List <double>(original.trainedClasses);
 }
        public override void RecalculateModelParameters(IClassificationProblemData problemData, IEnumerable <int> rows)
        {
            var estimatedValues = Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, problemData.Dataset, rows)
                                  .LimitToRange(LowerEstimationLimit, UpperEstimationLimit);
            var targetValues           = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
            var trainedClasses         = targetValues.ToArray();
            var trainedEstimatedValues = estimatedValues.ToArray();

            Array.Sort(trainedEstimatedValues, trainedClasses);
            this.trainedClasses         = new List <double>(trainedClasses);
            this.trainedEstimatedValues = new List <double>(trainedEstimatedValues);

            var freq = trainedClasses
                       .GroupBy(c => c)
                       .ToDictionary(g => g.Key, g => g.Count());

            this.frequencyComparer = new ClassFrequencyComparer(freq);
        }
 public SymbolicNearestNeighbourClassificationModel(string targetVariable, int k, ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue)
     : base(targetVariable, tree, interpreter, lowerEstimationLimit, upperEstimationLimit)
 {
     this.k            = k;
     frequencyComparer = new ClassFrequencyComparer();
 }
 public ClassFrequencyComparer(ClassFrequencyComparer original)
 {
     classFrequencies = new Dictionary <double, int>(original.classFrequencies);
 }