Пример #1
0
        /// <summary>
        /// Calculate the error for this neural network. The error is calculated
        /// using root-mean-square(RMS).
        /// </summary>
        /// <param name="input">Input patterns.</param>
        /// <param name="ideal">Ideal patterns.</param>
        /// <returns>The error percentage.</returns>
        public double CalculateError(double[][] input, double[][] ideal)
        {
            ErrorCalculation errorCalculation = new ErrorCalculation();

            for (int i = 0; i < ideal.Length; i++)
            {
                ComputeOutputs(input[i]);
                errorCalculation.UpdateError(this.outputLayer.Fire,
                        ideal[i]);
            }
            return (errorCalculation.CalculateRMS());
        }
Пример #2
0
        //pass data to other from here.
        public void display()
        {
            double[] present = new double[INPUT_SIZE * 4];
            double[] predict = new double[OUTPUT_SIZE * 3];
            double[] actualOutput = new double[OUTPUT_SIZE * 3];

            int index = 0;
            foreach (WeatherSamples sample in this.actual.getSamples())
            {
                if (sample.getDate().CompareTo(this.PREDICT_FROM) > 0)
                {
                    StringBuilder str = new StringBuilder();
                    str.Append(ReadCSV.DisplayDate(sample.getDate()));
                    str.Append(":Start=");
                    //str.Append(sample.airPollutionLevel);
                    //str.Append(sample.minTemp);
                    //str.Append(sample.maxTemp);
                    //str.Append(sample.rainfall);

                    this.actual.getInputData(index - INPUT_SIZE, present);
                     //DateTime date= ReadCSV.ParseDate("2010-04-19");
                     //this.actual.getInputDataToPredict(date,present);
                    this.actual.getOutputData(index - INPUT_SIZE, actualOutput);

                    predict = this.network.ComputeOutputs(present);
                    str.Append(",Actual minTemp =");
                    str.Append(actualOutput[0].ToString("N2"));
                    str.Append(",Actual maxTemp =");
                    str.Append(actualOutput[1].ToString("N2"));
                    str.Append(",Actual rainfall =");
                    str.Append(actualOutput[2].ToString("N2"));
                    str.Append(",Predicted minTemp= ");
                    str.Append(predict[0].ToString("N2"));
                    str.Append(",Predicted maxTemp= ");
                    str.Append(predict[1].ToString("N2"));
                    str.Append(",Predicted rainfall= ");
                    str.Append(predict[2].ToString("N2"));

                    str.Append(":Difference=");

                    ErrorCalculation error = new ErrorCalculation();
                    error.UpdateError(predict, actualOutput);
                    str.Append(error.CalculateRMS().ToString("N2"));

                    //

                    Console.WriteLine(str.ToString());
                }

                index++;
            }
        }