Exemplo n.º 1
0
        /// <summary>
        /// parse from data file path
        /// </summary>
        public void parseDataFile(string dataFile)
        {
            FileParsers parser = new FileParsers(dataFile, DATAFILE);

            int numSample = parser.DataLines.Count;

            String[] rawSample;
            for (int i = 0; i < numSample - 1; i++)
            {
                rawSample = parser.extractDataSample(i);

                int[] dataSample = new int[Attributes.Count];

                try
                {
                    // 2.a. Deal with all the attributes.
                    for (int j = 0; j < rawSample.Length; j++)
                    {
                        // There should be a 1-to-1 ordering between
                        // the internal attributes vector and the
                        // raw sample vector.
                        Attribute currAtt = (Attribute)Attributes.ElementAt(j);

                        int attPos = currAtt.getAttributeValuePosition((String)rawSample.ElementAt(j));
                        dataSample[j] = attPos;

                        if (j == 0)
                        {
                            TargetSums[attPos]++;
                        }
                    }
                }
                catch (Exception e)
                {
                }
                TrainingSet.Add(dataSample);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// parse from data file path
        /// </summary>        
        public void parseDataFile(string dataFile)
        {
            FileParsers parser = new FileParsers(dataFile, DATAFILE);

            int numSample = parser.DataLines.Count;

            String[] rawSample;
            for (int i = 0; i < numSample -1; i++)
            {
                rawSample = parser.extractDataSample(i);

                int[] dataSample = new int[Attributes.Count];

                try
                {
                    // 2.a. Deal with all the attributes.
                    for (int j = 0; j < rawSample.Length; j++)
                    {
                        // There should be a 1-to-1 ordering between
                        // the internal attributes vector and the
                        // raw sample vector.
                        Attribute currAtt = (Attribute)Attributes.ElementAt(j);

                        int attPos = currAtt.getAttributeValuePosition((String)rawSample.ElementAt(j));
                        dataSample[j] = attPos;

                        if (j == 0) TargetSums[attPos]++;
                    }
                }
                catch (Exception e)
                {
                }
                TrainingSet.Add(dataSample);
            }
        }