コード例 #1
0
 public override void Train(List <double[]> trainingData, List <double> trainingLabels, bool calculateError = true)
 {
     int[]      TrainingLabels = TypeCasters.DoubleArrayToInt(trainingLabels).ToArray();
     double[][] TrainingData   = trainingData.ToArray();
     Model = LearningAlgorithm.Learn(TrainingData, TrainingLabels);
     if (calculateError == true)
     {
         CalculateTrainingError(trainingData, trainingLabels);
     }
 }
コード例 #2
0
        public override dynamic Calculate(dynamic data)
        {
            var Mean = Accord.Statistics.Measures.Mean(data);
            var STD  = Accord.Statistics.Measures.StandardDeviation(data);

            double[] newData = ((double[])data);
            newData.Apply <double, double>((double value) => {
                return((value - Mean) / STD);
            });

            return(new double[] { newData[1], TypeCasters.SubArray <double>(newData, 1, 5).Sum(), TypeCasters.SubArray <double>(newData, 6, 10).Sum() });
        }
コード例 #3
0
        public override void Train(List <double[]> trainingData, List <double> trainingLabels, bool calculateError = true)
        {
            int[][] TrainingData   = TypeCasters.DoubleMultiArrayToInt(trainingData).ToArray();
            int[]   TrainingLabels = TypeCasters.DoubleArrayToInt(trainingLabels).ToArray();
            if (LearningAlgorithmName == DecisionTreeLearningAlgorithms.ID3Learning)
            {
                LearningAlgorithm = new ID3Learning();
            }
            else
            {
                LearningAlgorithm = new C45Learning();
            }

            Model = LearningAlgorithm.Learn(TrainingData, TrainingLabels);
            if (calculateError == true)
            {
                CalculateTrainingError(trainingData, trainingLabels);
            }
        }
コード例 #4
0
        public override void Train(List <double[]> trainingData, List <double> trainingLabels, bool calculateError = true)
        {
            LearningAlgorithm = new RandomForestLearning();
            if (NumTrees > 0)
            {
                LearningAlgorithm.NumberOfTrees = NumTrees;
            }

            if (SamplePropotion > 0)
            {
                LearningAlgorithm.SampleRatio = SamplePropotion;
            }
            int[][] TrainingData   = TypeCasters.DoubleMultiArrayToInt(trainingData).ToArray();
            int[]   TrainingLabels = TypeCasters.DoubleArrayToInt(trainingLabels).ToArray();

            Model = LearningAlgorithm.Learn(TrainingData, TrainingLabels);
            if (calculateError == true)
            {
                TrainingError = new ZeroOneLoss(TrainingLabels).Loss(Model.Decide(TrainingData));
            }
        }