Exemplo n.º 1
0
        private RCConfiguration _GetELMConfigurationFromPSOParticle(Particula particle, DataProvider dProv)
        {
            int inputNodesLengh = particle.GetFlagCountFromSubListValues((int)dProv.InputsN);

            if (inputNodesLengh == 0)
            {
                particle.PosicaoAtual[0] = 1;
                inputNodesLengh = particle.GetFlagCountFromSubListValues((int)dProv.InputsN);
            }

            Data[] dataSet = new Data[dProv.DataSetLines];
            int index = 0;

            for (int i = 0; i < dProv.DataSetLines; i++)
            {
                index = 0;
                dataSet[i] = new Data(new double[inputNodesLengh], new double[dProv.OutputsN]);
                dataSet[i].Output = dProv.DataSet[i].Output;

                for (int k = 0; k < dProv.InputsN; k++)
                {
                    if (particle.PosicaoAtual[k] == 1)
                    {
                        dataSet[i].Input[index] = dProv.DataSet[i].Input[k];
                        index++;
                    }
                }
            }

            DataProvider prov = new DataProvider(dataSet, EExecutionType.Predction, Util.Random);
            int hiddenNodes = particle.GetHiddenNodes((int)dProv.InputsN, MaxHiddenNodes);

            if (hiddenNodes == 0)
            {
                particle.PosicaoAtual[(int)dProv.InputsN] = 1;
                hiddenNodes = particle.GetHiddenNodes((int)dProv.InputsN, MaxHiddenNodes);
            }

            prov.MaxClassificationClass = dProv.MaxClassificationClass;

            return new RCConfiguration(prov, hiddenNodes, 1, 0.05, 1, EActivationFunctionType.SigmoidLogistic, EExecutionType.Predction);
        }
Exemplo n.º 2
0
        private void _ELM(Particula p)
        {
            DataProvider prov = new DataProvider(_DataSetPath, EExecutionType.Predction, Util.Random);

            RCConfiguration config = _GetELMConfigurationFromPSOParticle(p, prov);

            config.Prov.MaxValue = prov.MaxValue.Clone() as double[];
            config.Prov.MinValue = prov.MinValue.Clone() as double[];
            config.Prov.NormalizeData(inputA, inputB, outputA, outputB);

            config.Prov.ShuffleDataSet(1);
            config.Prov.SplitData();

            RC elm = new RC(config.Prov.TrainSet, config.Prov.ValidationSet, config);

            try
            {
                elm.Run();
            }
            catch
            { }

            RCEvaluator eval = new RCEvaluator(elm, EEvaluationInfo.EMQ | EEvaluationInfo.DEV | EEvaluationInfo.EPMA);

            eval.Evaluate();

            double fitness = eval.TrainEPMA + (2 * eval.ValidationDEV * p.GetFlagCountFromSubListValues((int)config.Prov.InputsN) / config.Prov.ValidationSetLines) + (config.HidenNodesNumber / MaxHiddenNodes);

            p.Eval = eval;
            p.Fitness = fitness;
            p.Config = config;

            count++;

            // Variação de C1 e C2
            if (_VariarC1C2)
            {
                if (count % _LimiteVariacaoC1C2 == 0)
                {
                    _C1 = _C1 - _TaxaVariacaoC1C2;
                    _C2 = _C2 + _TaxaVariacaoC1C2;
                }
            }

            // Variação de W
            if (_VariarW)
            {
                if (count % _LimiteVariacaoW == 0)
                    _W = _W - _TaxaVariacaoW;
            }
        }