示例#1
0
 /// <summary>
 /// Construct the analyst wizard.
 /// </summary>
 ///
 /// <param name="theAnalyst">The analyst to use.</param>
 public AnalystWizard(EncogAnalyst theAnalyst)
 {
     _directClassification = false;
     _taskSegregate        = true;
     _taskRandomize        = true;
     _taskNormalize        = true;
     _taskBalance          = false;
     _taskCluster          = true;
     _range              = NormalizeRange.NegOne2One;
     _analyst            = theAnalyst;
     _script             = _analyst.Script;
     _methodType         = WizardMethodType.FeedForward;
     _targetField        = "";
     _goal               = AnalystGoal.Classification;
     _leadWindowSize     = 0;
     _lagWindowSize      = 0;
     _includeTargetField = false;
     _missing            = new DiscardMissing();
 }
示例#2
0
        /// <summary>
        /// Extract fields from a file into a numeric array for machine learning.
        /// </summary>
        ///
        /// <param name="analyst">The analyst to use.</param>
        /// <param name="headers">The headers for the input data.</param>
        /// <param name="csv">The CSV that holds the input data.</param>
        /// <param name="outputLength">The length of the returned array.</param>
        /// <param name="skipOutput">True if the output should be skipped.</param>
        /// <returns>The encoded data.</returns>
        public static double[] ExtractFields(EncogAnalyst analyst,
                                             CSVHeaders headers, ReadCSV csv,
                                             int outputLength, bool skipOutput)
        {
            var output      = new double[outputLength];
            int outputIndex = 0;

            foreach (AnalystField stat in analyst.Script.Normalize.NormalizedFields)
            {
                if (stat.Action == NormalizationAction.Ignore)
                {
                    continue;
                }

                if (stat.Output && skipOutput)
                {
                    continue;
                }

                int    index = headers.Find(stat.Name);
                String str   = csv.Get(index);

                // is this an unknown value?
                if (str.Equals("?") || str.Length == 0)
                {
                    IHandleMissingValues handler = analyst.Script.Normalize.MissingValues;
                    double[]             d       = handler.HandleMissing(analyst, stat);

                    // should we skip the entire row
                    if (d == null)
                    {
                        return(null);
                    }

                    // copy the returned values in place of the missing values
                    for (int i = 0; i < d.Length; i++)
                    {
                        output[outputIndex++] = d[i];
                    }
                }
                else
                {
                    // known value

                    if (stat.Action == NormalizationAction.Normalize)
                    {
                        double d = csv.Format.Parse(str.Trim());
                        d = stat.Normalize(d);
                        output[outputIndex++] = d;
                    }
                    else
                    {
                        double[] d = stat.Encode(str.Trim());

                        foreach (double element in d)
                        {
                            output[outputIndex++] = element;
                        }
                    }
                }
            }

            return(output);
        }
示例#3
0
 public AnalystWizard(EncogAnalyst theAnalyst)
 {
     if (15 == 0)
     {
         return;
     }
     this._x7047063a9bee4054 = true;
     Label_0071:
     this._xc24b506a94383a44 = false;
     this._x34231b3d9a1591be = true;
     this._x9b10ace6509508c0 = NormalizeRange.NegOne2One;
     this._x554f16462d8d4675 = theAnalyst;
     this._x594135906c55045c = this._x554f16462d8d4675.Script;
     this._xa24f4208aa2278f4 = WizardMethodType.FeedForward;
     this._x0768e2edc97194de = "";
     if (8 != 0)
     {
         this._x29c8e5bee3cb25f8 = AnalystGoal.Classification;
         this._xb6540cd895237850 = 0;
         if (1 != 0)
         {
             this._x654428e3563552e3 = 0;
             this._x0236ea04f9fa4aaa = false;
             this._x771edacf1be2c386 = new DiscardMissing();
         }
         else
         {
             goto Label_0071;
         }
     }
 }
 /// <summary>
 ///     Construct the analyst wizard.
 /// </summary>
 /// <param name="theAnalyst">The analyst to use.</param>
 public AnalystWizard(EncogAnalyst theAnalyst)
 {
     _directClassification = false;
     _taskSegregate = true;
     _taskRandomize = true;
     _taskNormalize = true;
     _taskBalance = false;
     _taskCluster = true;
     _range = NormalizeRange.NegOne2One;
     _analyst = theAnalyst;
     _script = _analyst.Script;
     _methodType = WizardMethodType.FeedForward;
     TargetFieldName = "";
     _goal = AnalystGoal.Classification;
     _leadWindowSize = 0;
     _lagWindowSize = 0;
     _includeTargetField = false;
     _missing = new DiscardMissing();
     MaxError = DefaultTrainError;
     NaiveBayes = false;
 }