Exemplo n.º 1
0
        public void TestRPROPFolded()
        {
            IMLDataSet trainingData = XOR.CreateNoisyXORDataSet(10);

            BasicNetwork network = NetworkUtil.CreateXORNetworkUntrained();

            var folded = new FoldedDataSet(trainingData);
            IMLTrain train = new ResilientPropagation(network, folded);
            var trainFolded = new CrossValidationKFold(train, 4);

            EncogUtility.TrainToError(trainFolded, 0.2);

            XOR.VerifyXOR((IMLRegression) trainFolded.Method, 0.2);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Create a trainer, use cross validation if enabled.
        /// </summary>
        /// <param name="method">The method to use.</param>
        /// <param name="trainingSet">The training set to use.</param>
        /// <returns>The trainer.</returns>
        private IMLTrain CreateTrainer(IMLMethod method,
            IMLDataSet trainingSet)
        {
            var factory = new MLTrainFactory();

            String type = Prop.GetPropertyString(
                ScriptProperties.MlTrainType);
            String args = Prop.GetPropertyString(
                ScriptProperties.MlTrainArguments);

            EncogLogging.Log(EncogLogging.LevelDebug, "training type:" + type);
            EncogLogging.Log(EncogLogging.LevelDebug, "training args:" + args);

            IMLTrain train = factory.Create(method, trainingSet, type, args);

            if (_kfold > 0)
            {
                train = new CrossValidationKFold(train, _kfold);
            }

            return train;
        }