Beispiel #1
0
        public static double MeanAbsoluteError(double[][] expected, double[][] predicted)
        {
            var loss = new AbsoluteLoss(expected);

            loss.Mean = true;
            return(loss.Loss(predicted));
        }
Beispiel #2
0
        public static double MeanAbsoluteError(double[] expected, double[] predicted)
        {
            var e    = new double[1][] { expected };
            var p    = new double[1][] { predicted };
            var loss = new AbsoluteLoss(e);

            loss.Mean = true;
            return(loss.Loss(p));
        }
        private static void DisplayTrainingResults(string name, LearnerMatrix learnerMatrix,
                                                   Frame <int, string> testData)
        {
            Console.WriteLine($"{name}:");

            var labels      = testData["median_house_value"].Values.ToArray();
            var predictions = learnerMatrix.Transform(testData);

            var rmse = Math.Sqrt(new SquareLoss(labels).Loss(predictions));
            var mae  = new AbsoluteLoss(labels.ToJagged()).Loss(predictions.ToJagged()) / labels.Length;

            var range = Math.Abs(labels.Max() - labels.Min());

            Console.WriteLine($"Label range: {range}");
            Console.WriteLine($"RMSE:        {rmse} {rmse / range * 100:0.00}%");
            Console.WriteLine($"MAE:        {mae} {mae / range * 100:0.00}%");
            Console.WriteLine();
        }