Encog.App.Analyst.Wizard.AnalystWizard.DetermineTargetField C# (CSharp) Метод

DetermineTargetField() приватный Метод

Determine the target field.
private DetermineTargetField ( ) : void
Результат void
        private void DetermineTargetField()
        {
            IList<AnalystField> fields = _script.Normalize.NormalizedFields;

            if (_targetField.Trim().Length == 0)
            {
                bool success = false;

                if (_goal == AnalystGoal.Classification)
                {
                    // first try to the last classify field
                    foreach (AnalystField field  in  fields)
                    {
                        DataField df = _script.FindDataField(field.Name);
                        if (field.Action.IsClassify() && df.Class)
                        {
                            _targetField = field.Name;
                            success = true;
                        }
                    }
                }
                else
                {
                    // otherwise, just return the last regression field
                    foreach (AnalystField field  in  fields)
                    {
                        DataField df = _script.FindDataField(field.Name);
                        if (!df.Class && (df.Real || df.Integer))
                        {
                            _targetField = field.Name;
                            success = true;
                        }
                    }
                }

                if (!success)
                {
                    throw new AnalystError(
                        "Can't determine target field automatically, "
                        + "please specify one.\nThis can also happen if you "
                        + "specified the wrong file format.");
                }
            }
            else
            {
                if (_script.FindDataField(_targetField) == null)
                {
                    throw new AnalystError("Invalid target field: "
                                           + _targetField);
                }
            }

            _script.Properties.SetProperty(
                ScriptProperties.DataConfigGoal, _goal);

            if (!_timeSeries && _taskBalance)
            {
                _script.Properties.SetProperty(
                    ScriptProperties.BalanceConfigBalanceField,
                    _targetField);
                DataField field = _analyst.Script.FindDataField(
                    _targetField);
                if ((field != null) && field.Class)
                {
                    int countPer = field.MinClassCount;
                    _script.Properties.SetProperty(
                        ScriptProperties.BalanceConfigCountPer, countPer);
                }
            }

            // now that the target field has been determined, set the analyst fields
            AnalystField af = null;

            foreach (AnalystField field  in  _analyst.Script.Normalize.NormalizedFields)
            {
                if ((field.Action != NormalizationAction.Ignore)
                    && field.Name.Equals(_targetField, StringComparison.InvariantCultureIgnoreCase))
                {
                    if ((af == null) || (af.TimeSlice < field.TimeSlice))
                    {
                        af = field;
                    }
                }
            }

            if (af != null)
            {
                af.Output = true;
            }

            // set the clusters count
            if (_taskCluster)
            {
                if ((_targetField.Length == 0)
                    || (_goal != AnalystGoal.Classification))
                {
                    _script.Properties.SetProperty(
                        ScriptProperties.ClusterConfigClusters, 2);
                }
                else
                {
                    DataField tf = _script
                        .FindDataField(_targetField);
                    _script.Properties.SetProperty(
                        ScriptProperties.ClusterConfigClusters,
                        tf.ClassMembers.Count);
                }
            }
        }