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); } }
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() }); }
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); } }
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)); } }