public double MeasurePerformance(IMLRegression network, BasicNeuralDataSet dataset, IActivationFunction activationFunction)
        {
            int         correctBits = 0;
            const float Threshold   = 0.0f;

            if (!(activationFunction is ActivationTANH))
            {
                throw new ArgumentException("Bad activation function");
            }

            int n = (int)dataset.Count;

            for (int inputIndex = 0; inputIndex < n; inputIndex++)
            {
                var actualOutputs = network.Compute(dataset.Data[inputIndex].Input);
                for (int outputIndex = 0, k = actualOutputs.Count; outputIndex < k; outputIndex++)
                {
                    if (IsBothPositiveBits(actualOutputs[outputIndex], dataset.Data[inputIndex].Ideal[outputIndex], Threshold) ||
                        IsBothNegativeBits(actualOutputs[outputIndex], dataset.Data[inputIndex].Ideal[outputIndex], Threshold))
                    {
                        correctBits++;
                    }
                }
            }

            long totalBitsCount = dataset.Count * dataset.Data[0].Ideal.Count;

            return((double)correctBits / totalBitsCount);
        }
        public void traning(string traningexamplespath)
        {
            IVersatileDataSource source = new CSVDataSource(traningexamplespath, false, CSVFormat.DecimalPoint);
            var data = new VersatileMLDataSet(source);

            data.DefineSourceColumn("num1", 0, ColumnType.Continuous);
            data.DefineSourceColumn("num2", 1, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 2, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 3, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 4, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 5, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 6, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 7, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 8, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 9, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 10, ColumnType.Continuous);
            data.DefineSourceColumn("num1", 11, ColumnType.Continuous);
            ColumnDefinition outputColumn = data.DefineSourceColumn("kind", 12, ColumnType.Nominal);

            data.Analyze();
            data.DefineSingleOutputOthersInput(outputColumn);


            var model = new EncogModel(data);

            model.SelectMethod(data, MLMethodFactory.TypeFeedforward);

            // Send any output to the console.
            model.Report = new ConsoleStatusReportable();

            // Now normalize the data.  Encog will automatically determine the correct normalization
            // type based on the model you chose in the last step.
            data.Normalize();

            model.HoldBackValidation(0.3, true, 1001);

            // Choose whatever is the default training type for this model.
            model.SelectTrainingType(data);

            // Use a 5-fold cross-validated train.  Return the best method found.
            bestMethod = (IMLRegression)model.Crossvalidate(5, true);

            //Console.WriteLine(@"Training error: " + model.CalculateError(bestMethod, model.TrainingDataset));
            //Console.WriteLine(@"Validation error: " + model.CalculateError(bestMethod, model.ValidationDataset));

            // Display our normalization parameters.
            helper = data.NormHelper;
            // Console.WriteLine(helper.ToString());

            // Display the final model.
            //Console.WriteLine(@"Final model: " + bestMethod);
            source.Close();

            saveNetwork("save.eg");
            savehelper("helper.hp");
            //EncogFramework.Instance.Shutdown();
        }
Exemple #3
0
 public void Analyze(IMLRegression method, FileInfo inputFile, bool headers, CSVFormat format)
 {
     object[] objArray;
     base.InputFilename = inputFile;
     base.ExpectInputHeaders = headers;
     base.InputFormat = format;
     if (((uint) headers) >= 0)
     {
         base.Analyzed = true;
     }
     base.PerformBasicCounts();
     this._x43f451310e815b76 = method.InputCount;
     this._x98cf41c6b0eaf6ab = method.OutputCount;
     this._xb52d4a98fad404da = Math.Max(base.InputHeadings.Length - this._x43f451310e815b76, 0);
     if (0x7fffffff == 0)
     {
         goto Label_00E0;
     }
     if ((((uint) headers) & 0) != 0)
     {
         goto Label_0084;
     }
     if ((((uint) headers) - ((uint) headers)) >= 0)
     {
         if (base.InputHeadings.Length == this._x43f451310e815b76)
         {
             return;
         }
         if (3 == 0)
         {
             return;
         }
     }
     Label_000C:
     if (base.InputHeadings.Length != (this._x43f451310e815b76 + this._x98cf41c6b0eaf6ab))
     {
         objArray = new object[7];
         goto Label_00E0;
     }
     return;
     Label_0084:
     objArray[3] = this._x43f451310e815b76;
     if ((((uint) headers) + ((uint) headers)) < 0)
     {
         goto Label_000C;
     }
     objArray[4] = ") count or input+output(";
     objArray[5] = this._x43f451310e815b76 + this._x98cf41c6b0eaf6ab;
     objArray[6] = ") count.";
     throw new AnalystError(string.Concat(objArray));
     Label_00E0:
     objArray[0] = "Invalid number of columns(";
     objArray[1] = base.InputHeadings.Length;
     objArray[2] = "), must match input(";
     goto Label_0084;
 }
Exemple #4
0
        /// <summary>
        ///     Process the file.
        /// </summary>
        /// <param name="outputFile">The output file.</param>
        /// <param name="method">The method to use.</param>
        public void Process(FileInfo outputFile, IMLRegression method)
        {
            var csv = new ReadCSV(InputFilename.ToString(),
                                  ExpectInputHeaders, Format);

            if (method.InputCount != _inputCount)
            {
                throw new AnalystError("This machine learning method has "
                                       + method.InputCount
                                       + " inputs, however, the data has " + _inputCount
                                       + " inputs.");
            }

            var input = new BasicMLData(method.InputCount);

            StreamWriter tw = AnalystPrepareOutputFile(outputFile);

            ResetStatus();
            while (csv.Next())
            {
                UpdateStatus(false);
                var row = new LoadedRow(csv, _idealCount);

                int dataIndex = 0;
                // load the input data
                for (int i = 0; i < _inputCount; i++)
                {
                    String str = row.Data[i];
                    double d   = Format.Parse(str);
                    input[i] = d;
                    dataIndex++;
                }

                // do we need to skip the ideal values?
                dataIndex += _idealCount;

                // compute the result
                IMLData output = method.Compute(input);

                // display the computed result
                for (int i = 0; i < _outputCount; i++)
                {
                    double d = output[i];
                    row.Data[dataIndex++] = Format.Format(d, Precision);
                }

                WriteRow(tw, row);
            }
            ReportDone(false);
            tw.Close();
            csv.Close();
        }
Exemple #5
0
 /// <summary>
 /// Evaluate the network and display (to the console) the output for every
 /// value in the training set. Displays ideal and actual.
 /// </summary>
 /// <param name="network">The network to evaluate.</param>
 /// <param name="training">The training set to evaluate.</param>
 public static void Evaluate(IMLRegression network,
                             IMLDataSet training)
 {
     foreach (IMLDataPair pair in training)
     {
         IMLData output = network.Compute(pair.Input);
         Console.WriteLine(@"Input="
                           + FormatNeuralData(pair.Input)
                           + @", Actual=" + FormatNeuralData(output)
                           + @", Ideal="
                           + FormatNeuralData(pair.Ideal));
     }
 }
 public int loadNetwork(string name)
 {
     try
     {
         System.IO.FileInfo info = new System.IO.FileInfo(name);
         bestMethod = (IMLRegression)EncogDirectoryPersistence.LoadObject(info);
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Exemple #7
0
        /// <summary>
        /// Calculate a regression error.
        /// </summary>
        /// <param name="method">The method to check.</param>
        /// <param name="data">The data to check.</param>
        /// <returns>The error.</returns>
        public static double CalculateRegressionError(IMLRegression method,
                                                      IMLDataSet data)
        {
            var errorCalculation = new ErrorCalculation();
            if (method is IMLContext)
                ((IMLContext)method).ClearContext();

            foreach (IMLDataPair pair in data)
            {
                IMLData actual = method.Compute(pair.Input);
                errorCalculation.UpdateError(actual, pair.Ideal, pair.Significance);
            }
            return errorCalculation.Calculate();
        }
Exemple #8
0
 public static double CalculateRegressionError(IMLRegression method, IMLDataSet data)
 {
     ErrorCalculation calculation = new ErrorCalculation();
     if (method is IMLContext)
     {
         ((IMLContext) method).ClearContext();
     }
     foreach (IMLDataPair pair in data)
     {
         IMLData data2 = method.Compute(pair.Input);
         calculation.UpdateError(data2.Data, pair.Ideal.Data, pair.Significance);
     }
     return calculation.Calculate();
 }
        /// <summary>
        /// Construct the indicator. 
        /// </summary>
        /// <param name="theMethod">The machine learning method to use.</param>
        /// <param name="thePath">The path to use.</param>
        public MyInd(IMLRegression theMethod, string thePath)
            : base(theMethod != null)
        {
            _method = theMethod;
            _path = thePath;

            RequestData("CLOSE[1]");
            RequestData("SMA(10)[" + Config.InputWindow + "]");
            RequestData("SMA(25)[" + Config.InputWindow + "]");

            _fieldDifference = new NormalizedField(NormalizationAction.Normalize, "diff", Config.DiffRange,
                                                  -Config.DiffRange, 1, -1);
            _fieldOutcome = new NormalizedField(NormalizationAction.Normalize, "out", Config.PipRange, -Config.PipRange,
                                               1, -1);
        }
Exemple #10
0
        /// <summary>
        /// Construct the indicator.
        /// </summary>
        /// <param name="theMethod">The machine learning method to use.</param>
        /// <param name="thePath">The path to use.</param>
        public MyInd(IMLRegression theMethod, string thePath)
            : base(theMethod != null)
        {
            _method = theMethod;
            _path   = thePath;

            RequestData("CLOSE[1]");
            RequestData("SMA(10)[" + Config.InputWindow + "]");
            RequestData("SMA(25)[" + Config.InputWindow + "]");

            _fieldDifference = new NormalizedField(NormalizationAction.Normalize, "diff", Config.DiffRange,
                                                   -Config.DiffRange, 1, -1);
            _fieldOutcome = new NormalizedField(NormalizationAction.Normalize, "out", Config.PipRange, -Config.PipRange,
                                                1, -1);
        }
Exemple #11
0
        public static bool VerifyXOR(IMLRegression network, double tolerance)
        {
            for (int trainingSet = 0; trainingSet < XORIdeal.Length; trainingSet++)
            {
                var actual = network.Compute(new BasicMLData(XORInput[trainingSet]));

                for (var i = 0; i < XORIdeal[0].Length; i++)
                {
                    double diff = Math.Abs(actual[i] - XORIdeal[trainingSet][i]);
                    if (diff > tolerance)
                        return false;
                }
            }

            return true;
        }
Exemple #12
0
        /// <inheritdoc/>
        public override sealed bool ExecuteCommand(String args)
        {
            // get filenames
            String evalID = Prop.GetPropertyString(
                ScriptProperties.MlConfigEvalFile);
            String resourceID = Prop.GetPropertyString(
                ScriptProperties.MlConfigMachineLearningFile);

            String outputID = Prop.GetPropertyString(
                ScriptProperties.MlConfigOutputFile);

            EncogLogging.Log(EncogLogging.LevelDebug, "Beginning evaluate raw");
            EncogLogging.Log(EncogLogging.LevelDebug, "evaluate file:" + evalID);
            EncogLogging.Log(EncogLogging.LevelDebug, "resource file:"
                             + resourceID);

            FileInfo evalFile     = Script.ResolveFilename(evalID);
            FileInfo resourceFile = Script.ResolveFilename(resourceID);

            FileInfo outputFile = Analyst.Script.ResolveFilename(
                outputID);

            IMLMethod m = (IMLMethod)EncogDirectoryPersistence.LoadObject(resourceFile);

            if (!(m is IMLRegression))
            {
                throw new AnalystError("The evaluate raw command can only be used with regression.");
            }

            IMLRegression method = (IMLRegression)m;

            bool headers = Script.ExpectInputHeaders(evalID);

            var eval = new AnalystEvaluateRawCSV {
                Script = Script
            };

            Analyst.CurrentQuantTask = eval;
            eval.Report = new AnalystReportBridge(Analyst);
            eval.Analyze(Analyst, evalFile, headers, Prop
                         .GetPropertyCSVFormat(ScriptProperties.SetupConfigCSVFormat));
            eval.Process(outputFile, method);
            Analyst.CurrentQuantTask = null;
            return(eval.ShouldStop());
        }
Exemple #13
0
        public static bool VerifyXOR(IMLRegression network, double tolerance)
        {
            for (int trainingSet = 0; trainingSet < XORIdeal.Length; trainingSet++)
            {
                var actual = network.Compute(new BasicMLData(XORInput[trainingSet]));

                for (var i = 0; i < XORIdeal[0].Length; i++)
                {
                    double diff = Math.Abs(actual[i] - XORIdeal[trainingSet][i]);
                    if (diff > tolerance)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Calculate an error for a method that uses regression.
        /// </summary>
        /// <param name="method">The method to evaluate.</param>
        /// <param name="data">The training data to evaluate with.</param>
        /// <returns>The error.</returns>
        public static double CalculateError(IMLRegression method,
                                            IMLDataSet data)
        {
            var errorCalculation = new ErrorCalculation();

            // clear context
            if (method is IMLContext)
            {
                ((IMLContext) method).ClearContext();
            }

            // calculate error
            foreach (IMLDataPair pair  in  data)
            {
                IMLData actual = method.Compute(pair.Input);
                errorCalculation.UpdateError(actual, pair.Ideal, pair.Significance);
            }
            return errorCalculation.Calculate();
        }
        public double[][] ComputeAm(IMLRegression network, List <double[][]> spectralImages, int outputCount)
        {
            int counter    = 0;
            int trackCount = spectralImages.Count;

            double[][] am = new double[trackCount][];
            foreach (double[][] spectralImagesForTrack in spectralImages)
            {
                am[counter] = new double[outputCount];
                foreach (double[] snippet in spectralImagesForTrack)
                {
                    var actualOutput = network.Compute(new BasicMLData(snippet));
                    for (int binOutputIndex = 0; binOutputIndex < outputCount; binOutputIndex++)
                    {
                        am[counter][binOutputIndex] += actualOutput[binOutputIndex] / outputCount;
                    }
                }

                counter++;
            }

            return(am);
        }
        /// <summary>
        /// Analyze the data. This counts the records and prepares the data to be
        /// processed.
        /// </summary>
        ///
        /// <param name="inputFile">The input file.</param>
        /// <param name="headers">True if headers are present.</param>
        /// <param name="format">The format the file is in.</param>
        public void Analyze(IMLRegression method, FileInfo inputFile, bool headers, CSVFormat format)
        {
            InputFilename = inputFile;
            ExpectInputHeaders = headers;
            Format = format;

            Analyzed = true;

            PerformBasicCounts();

            _inputCount = method.InputCount;
            _outputCount = method.OutputCount;
            _idealCount = Math.Max( InputHeadings.Length - _inputCount, 0);

            if ((InputHeadings.Length != _inputCount)
                && (InputHeadings.Length != (_inputCount + _outputCount)))
            {
                throw new AnalystError("Invalid number of columns("
                                       + InputHeadings.Length + "), must match input("
                                       + _inputCount + ") count or input+output("
                                       + (_inputCount + _outputCount) + ") count.");
            }
        }
Exemple #17
0
        /// <summary>
        /// Analyze the data. This counts the records and prepares the data to be
        /// processed.
        /// </summary>
        ///
        /// <param name="inputFile">The input file.</param>
        /// <param name="headers">True if headers are present.</param>
        /// <param name="format">The format the file is in.</param>
        public void Analyze(IMLRegression method, FileInfo inputFile, bool headers, CSVFormat format)
        {
            InputFilename      = inputFile;
            ExpectInputHeaders = headers;
            Format             = format;

            Analyzed = true;

            PerformBasicCounts();

            _inputCount  = method.InputCount;
            _outputCount = method.OutputCount;
            _idealCount  = Math.Max(InputHeadings.Length - _inputCount, 0);

            if ((InputHeadings.Length != _inputCount) &&
                (InputHeadings.Length != (_inputCount + _outputCount)))
            {
                throw new AnalystError("Invalid number of columns("
                                       + InputHeadings.Length + "), must match input("
                                       + _inputCount + ") count or input+output("
                                       + (_inputCount + _outputCount) + ") count.");
            }
        }
 public MyFactory(IMLRegression theMethod, string thePath)
 {
     _method = theMethod;
     _path = thePath;
 }
        /// <summary>
        /// Process the file.
        /// </summary>
        ///
        /// <param name="outputFile">The output file.</param>
        /// <param name="method">The method to use.</param>
        public void Process(FileInfo outputFile, IMLRegression method)
        {
            var csv = new ReadCSV(InputFilename.ToString(),
                                  ExpectInputHeaders, Format);

            if (method.InputCount > _inputCount)
            {
                throw new AnalystError("This machine learning method has "
                                       + method.InputCount
                                       + " inputs, however, the data has " + _inputCount
                                       + " inputs.");
            }

            var input = new BasicMLData(method.InputCount);

            StreamWriter tw = AnalystPrepareOutputFile(outputFile);

            ResetStatus();
            while (csv.Next())
            {
                UpdateStatus(false);
                var row = new LoadedRow(csv, _idealCount);

                int dataIndex = 0;
                // load the input data
                for (int i = 0; i < _inputCount; i++)
                {
                    String str = row.Data[i];
                    double d = Format.Parse(str);
                    input[i] = d;
                    dataIndex++;
                }

                // do we need to skip the ideal values?
                dataIndex += _idealCount;

                // compute the result
                IMLData output = method.Compute(input);

                // display the computed result
                for (int i = 0; i < _outputCount; i++)
                {
                    double d = output[i];
                    row.Data[dataIndex++] = Format.Format(d, Precision);
                }

                WriteRow(tw, row);
            }
            ReportDone(false);
            tw.Close();
            csv.Close();
        }
 public PredictionMachine(IMLRegression neuralNet, NormalizationHelper normalizationHelper, PredictionConfig config)
 {
     NeuralNet            = neuralNet;
     _normalizationHelper = normalizationHelper;
     Config = config;
 }
 public MyFactory(IMLRegression theMethod, string thePath)
 {
     _method = theMethod;
     _path   = thePath;
 }
Exemple #22
0
 public void Process(FileInfo outputFile, IMLRegression method)
 {
     IMLData data;
     StreamWriter writer;
     LoadedRow row;
     int num;
     int num2;
     double num3;
     IMLData data2;
     int num4;
     double num5;
     object[] objArray;
     ReadCSV csv = new ReadCSV(base.InputFilename.ToString(), base.ExpectInputHeaders, base.InputFormat);
     goto Label_028E;
     Label_0022:
     if (csv.Next())
     {
         base.UpdateStatus(false);
         row = new LoadedRow(csv, this._xb52d4a98fad404da);
         num = 0;
         if ((((uint) num3) + ((uint) num4)) < 0)
         {
             goto Label_0208;
         }
         num2 = 0;
     }
     else
     {
         if ((((uint) num5) + ((uint) num2)) < 0)
         {
             goto Label_026E;
         }
         base.ReportDone(false);
         writer.Close();
         csv.Close();
         if (0 == 0)
         {
             return;
         }
         goto Label_028E;
     }
     Label_0125:
     if (num2 < this._x43f451310e815b76)
     {
         string str = row.Data[num2];
         num3 = base.InputFormat.Parse(str);
         data[num2] = num3;
         if ((((uint) num5) + ((uint) num3)) <= uint.MaxValue)
         {
             goto Label_0148;
         }
         goto Label_0196;
     }
     num += this._xb52d4a98fad404da;
     Label_013A:
     data2 = method.Compute(data);
     num4 = 0;
     goto Label_0196;
     Label_0148:
     num++;
     num2++;
     if ((((uint) num) - ((uint) num3)) > uint.MaxValue)
     {
         goto Label_01EC;
     }
     goto Label_0125;
     Label_0196:
     if ((((uint) num3) + ((uint) num3)) >= 0)
     {
     Label_008D:
         if (num4 >= this._x98cf41c6b0eaf6ab)
         {
             base.WriteRow(writer, row);
         }
         else
         {
             num5 = data2[num4];
             if ((((uint) num2) - ((uint) num)) < 0)
             {
                 goto Label_0125;
             }
             if ((((uint) num2) | 15) != 0)
             {
                 row.Data[num++] = base.InputFormat.Format(num5, base.Precision);
                 num4++;
                 goto Label_008D;
             }
         }
         if (((uint) num3) < 0)
         {
             if (((uint) num5) <= uint.MaxValue)
             {
                 goto Label_0125;
             }
             goto Label_0148;
         }
     }
     goto Label_02BE;
     Label_01EC:
     base.ResetStatus();
     goto Label_0022;
     Label_0208:
     data = new BasicMLData(method.InputCount);
     writer = this.x972236628de6c041(outputFile);
     if ((((uint) num5) + ((uint) num4)) >= 0)
     {
         goto Label_01EC;
     }
     goto Label_0125;
     Label_026E:
     objArray[4] = " inputs.";
     if (((uint) num2) < 0)
     {
         goto Label_013A;
     }
     if (((uint) num) >= 0)
     {
         throw new AnalystError(string.Concat(objArray));
     }
     goto Label_02BE;
     Label_028E:
     if (method.InputCount <= this._x43f451310e815b76)
     {
         goto Label_0208;
     }
     objArray = new object[5];
     objArray[0] = "This machine learning method has ";
     objArray[1] = method.InputCount;
     objArray[2] = " inputs, however, the data has ";
     objArray[3] = this._x43f451310e815b76;
     goto Label_026E;
     Label_02BE:
     if ((((uint) num) - ((uint) num2)) <= uint.MaxValue)
     {
         goto Label_0022;
     }
 }
Exemple #23
0
        /// <summary>
        /// Calculate the score for the network.
        /// </summary>
        ///
        /// <param name="method">The network to calculate for.</param>
        /// <returns>The score.</returns>
        public double CalculateScore(IMLMethod method)
        {
            IMLRegression reg = (IMLRegression)method;

            return(CalculateRegressionError.CalculateError(reg, _training));
        }
Exemple #24
0
 public static void Evaluate(IMLRegression network, IMLDataSet training)
 {
     using (IEnumerator<IMLDataPair> enumerator = training.GetEnumerator())
     {
         IMLDataPair pair;
         IMLData data;
         string[] strArray;
     Label_0009:
         if (!enumerator.MoveNext())
         {
             if (2 == 0)
             {
                 goto Label_005B;
             }
             if (0 == 0)
             {
                 return;
             }
         }
         goto Label_0095;
     Label_0026:
         strArray[4] = ", Ideal=";
     Label_002E:
         strArray[5] = x8d742ff2b6748ce6(pair.Ideal);
         Console.WriteLine(string.Concat(strArray));
         if (0 == 0)
         {
             goto Label_00A3;
         }
         goto Label_0095;
     Label_004C:
         strArray = new string[6];
         strArray[0] = "Input=";
     Label_005B:
         strArray[1] = x8d742ff2b6748ce6(pair.Input);
         strArray[2] = ", Actual=";
         strArray[3] = x8d742ff2b6748ce6(data);
         goto Label_0026;
     Label_007C:
         if (0 != 0)
         {
             goto Label_002E;
         }
         data = network.Compute(pair.Input);
         if (1 != 0)
         {
             goto Label_004C;
         }
         goto Label_0026;
     Label_0095:
         pair = enumerator.Current;
         goto Label_007C;
     Label_00A3:
         if (0xff != 0)
         {
             goto Label_0009;
         }
     }
 }
Exemple #25
0
 public void Process(FileInfo outputFile, IMLRegression method)
 {
     IMLData data;
     StreamWriter writer;
     LoadedRow row;
     int num;
     int num2;
     string str;
     double num3;
     IMLData data2;
     int num4;
     double num5;
     object[] objArray;
     ReadCSV csv = new ReadCSV(base.InputFilename.ToString(), base.ExpectInputHeaders, base.InputFormat);
     goto Label_0285;
     Label_006D:
     if (csv.Next())
     {
         base.UpdateStatus(false);
         row = new LoadedRow(csv, this._xb52d4a98fad404da);
         num = 0;
         if ((((uint) num2) | 4) == 0)
         {
             goto Label_011D;
         }
         goto Label_010D;
     }
     if ((((uint) num3) & 0) == 0)
     {
         base.ReportDone(false);
         writer.Close();
         csv.Close();
         if ((((uint) num) + ((uint) num3)) < 0)
         {
             if ((((uint) num) - ((uint) num2)) <= uint.MaxValue)
             {
                 goto Label_010D;
             }
             goto Label_00D5;
         }
     }
     if ((((uint) num) & 0) == 0)
     {
         return;
     }
     goto Label_0165;
     Label_00A6:
     if (((uint) num5) < 0)
     {
         goto Label_01F9;
     }
     num4++;
     Label_00C1:
     if (num4 < this._x98cf41c6b0eaf6ab)
     {
         num5 = data2[num4];
         row.Data[num++] = base.InputFormat.Format(num5, base.Precision);
         goto Label_00A6;
     }
     base.WriteRow(writer, row);
     goto Label_006D;
     Label_00D5:
     data2 = method.Compute(data);
     num4 = 0;
     goto Label_00C1;
     Label_00F6:
     if (num2 < this._x43f451310e815b76)
     {
         str = row.Data[num2];
         goto Label_011D;
     }
     Label_0100:
     num += this._xb52d4a98fad404da;
     goto Label_00D5;
     Label_010D:
     num2 = 0;
     goto Label_00F6;
     Label_011D:
     num3 = base.InputFormat.Parse(str);
     data[num2] = num3;
     num++;
     num2++;
     goto Label_00F6;
     Label_0165:
     if (0 != 0)
     {
         goto Label_00A6;
     }
     goto Label_006D;
     Label_01C8:
     data = new BasicMLData(method.InputCount);
     writer = this.x972236628de6c041(outputFile);
     if ((((uint) num) | 2) == 0)
     {
         goto Label_0100;
     }
     base.ResetStatus();
     goto Label_0165;
     Label_01F9:
     objArray[2] = " inputs, however, the data has ";
     if ((((uint) num4) + ((uint) num)) <= uint.MaxValue)
     {
         objArray[3] = this._x43f451310e815b76;
         objArray[4] = " inputs.";
         throw new AnalystError(string.Concat(objArray));
     }
     Label_0285:
     if (((((uint) num2) | 15) != 0) && (method.InputCount == this._x43f451310e815b76))
     {
         goto Label_01C8;
     }
     objArray = new object[5];
     objArray[0] = "This machine learning method has ";
     if ((((uint) num) - ((uint) num4)) > uint.MaxValue)
     {
         goto Label_01C8;
     }
     objArray[1] = method.InputCount;
     goto Label_01F9;
 }
Exemple #26
0
        public double CalculateScore(IMLRegression network)
        {
            NeuralPilot pilot = new NeuralPilot((BasicNetwork)network, false);

            return(pilot.ScorePilot());
        }
 /// <summary>
 /// Evaluate the network and display (to the console) the output for every
 /// value in the training set. Displays ideal and actual.
 /// </summary>
 /// <param name="network">The network to evaluate.</param>
 /// <param name="training">The training set to evaluate.</param>
 public static void Evaluate(IMLRegression network,
                             IMLDataSet training)
 {
     foreach (IMLDataPair pair in training)
     {
         IMLData output = network.Compute(pair.Input);
         Console.WriteLine(@"Input="
                           + FormatNeuralData(pair.Input)
                           + @", Actual=" + FormatNeuralData(output)
                           + @", Ideal="
                           + FormatNeuralData(pair.Ideal));
     }
 }
Exemple #28
0
 public double CalculateScore(IMLRegression method)
 {
     return CalculateRegressionError.CalculateError(method, this._x823a2b9c8bf459c5);
 }
 public double CalculateScore(IMLRegression network)
 {
     NeuralPilot pilot = new NeuralPilot((BasicNetwork)network, false);
     return pilot.ScorePilot();
 }
Exemple #30
0
 /// <summary>
 /// Calculate the score for the network.
 /// </summary>
 ///
 /// <param name="method">The network to calculate for.</param>
 /// <returns>The score.</returns>
 public double CalculateScore(IMLRegression method)
 {
     return(CalculateRegressionError.CalculateError(method, _training));
 }
Exemple #31
0
 /// <summary>
 /// Calculate the score for the network.
 /// </summary>
 ///
 /// <param name="method">The network to calculate for.</param>
 /// <returns>The score.</returns>
 public double CalculateScore(IMLRegression method)
 {
     return CalculateRegressionError.CalculateError(method, _training);
 }