Esempio n. 1
0
        /// <summary>
        /// Thực hiện đọc file MetaData để lấy thông tin
        /// </summary>
        /// <param name="metaFile">Đường dẫn file</param>
        public void parseMetaFile(string metaFile)
        {
            FileParsers parser     = new FileParsers(metaFile, METAFILE);
            String      targetName = parser.getAttributeName(0);

            String[] targetValues;
            int      numTargetValues;

            targetValues = parser.extractTargetAttributeValue(0);
            //// Build the target attribute and add it to the attributes vector.
            Attribute targetAttribute = new Attribute(targetName, targetValues, 1);

            numTargetValues = targetValues.Length;
            Attributes.Add(targetAttribute);

            List <Attribute> list = parser.extractAttributeFeatures();

            for (int i = 0; i < list.Count; i++)
            {
                Attributes.Add((Attribute)list[i]);
            }
        }
Esempio 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);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Thực hiện đọc file MetaData để lấy thông tin
        /// </summary>
        /// <param name="metaFile">Đường dẫn file</param>
        public void parseMetaFile(string metaFile)
        {
            FileParsers parser = new FileParsers(metaFile, METAFILE);
            String targetName = parser.getAttributeName(0);
            String[] targetValues ;
            int numTargetValues;

            targetValues = parser.extractTargetAttributeValue(0);
            //// Build the target attribute and add it to the attributes vector.
            Attribute targetAttribute = new Attribute(targetName, targetValues, 1);

            numTargetValues = targetValues.Length;
            Attributes.Add(targetAttribute);

            List<Attribute> list = parser.extractAttributeFeatures();
            for (int i = 0; i < list.Count; i++)
            {
                Attributes.Add((Attribute)list[i]);
            }
        }
Esempio n. 4
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);
            }
        }