Пример #1
0
 public static PartialMean FromString(string str)
 {
     if (string.IsNullOrWhiteSpace(str))
     {
         throw new ArgumentException("str");
     }
     string[] parts = str.Split('#');
     if (parts == null || parts.Length != 2)
     {
         throw new ArgumentException("Cannot deserialize PartialMean from string " + str);
     }
     return(new PartialMean(DataVector.FromString(parts[0]), int.Parse(parts[1], CultureInfo.InvariantCulture)));
 }
Пример #2
0
        // read initial data from file and marked it as unlabeled (not associated with any centroid)
        public static List <DataVector> ReadDataFile(string path, char seperator = ',')
        {
            List <DataVector> data = new List <DataVector>();
            FileStream        file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);

            using (StreamReader reader = new StreamReader(file))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        data.Add(DataVector.FromString(line));
                    }
                }
                reader.Close();
            }

            return(data);
        }