Example #1
0
        public Dataset NormalizarDataset(IEnumerable <Item> itensTreinamento)
        {
            //verifica se os atributos do dataset são numéricos
            var    xNumeric   = itensTreinamento.All(x => x.X.IsNumeric());
            var    yNumeric   = itensTreinamento.All(x => x.Y.IsNumeric());
            double maiorItemX = 0;
            double menorItemX = 0;
            double maiorItemY = 0;
            double menorItemY = 0;

            //caso sejam, é setado o maior e o menor valor dos itens
            if (xNumeric)
            {
                maiorItemX = itensTreinamento.Max(x => x.X.ValorNumerico);
                menorItemX = itensTreinamento.Min(x => x.X.ValorNumerico);
            }

            if (yNumeric)
            {
                maiorItemY = itensTreinamento.Max(x => x.Y.ValorNumerico);
                menorItemY = itensTreinamento.Min(x => x.Y.ValorNumerico);
            }

            var dataset = new Dataset
            {
                XNumeric = xNumeric,
                YNumeric = yNumeric,
                MaiorX   = maiorItemX,
                MenorX   = menorItemX,
                MaiorY   = maiorItemY,
                MenorY   = menorItemY
            };

            //os itens que vieram do dataset são normalizados
            dataset.AdicionarItensENormalizar(itensTreinamento);

            return(dataset);
        }