Exemple #1
0
        public void SetData(StreamReader reader, StreamReader reader_2 = null)
        {
            reader.DiscardBufferedData();
            reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                int      Sign;
                double[] Vector      = new double[68];
                string[] splitstring = line.Split();
                if (splitstring.First().First() == '+')
                {
                    Sign = +1;
                }
                else
                {
                    Sign = -1;
                }
                foreach (var item in splitstring)
                {
                    if (item.Contains(":"))
                    {
                        string[] s = item.Split(':');
                        Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]);
                    }
                }
                Training_Data.Add(new Entry(Sign, Vector));
            }
            if (reader_2 != null)
            {
                reader_2.DiscardBufferedData();
                reader_2.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                string line2;
                while ((line2 = reader_2.ReadLine()) != null)
                {
                    int      Sign;
                    double[] Vector      = new double[68];
                    string[] splitstring = line2.Split();
                    if (splitstring.First().First() == '+')
                    {
                        Sign = +1;
                    }
                    else
                    {
                        Sign = -1;
                    }
                    foreach (var item in splitstring)
                    {
                        if (item.Contains(":"))
                        {
                            string[] s = item.Split(':');
                            Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]);
                        }
                    }
                    Test_Data.Add(new Entry(Sign, Vector));
                }
            }
        }
 public void SetTrainingData()
 {
     foreach (var item in data_1)
     {
         Training_Data.Add(new TrainingData(ScreenNameLength(item.Vector[0]), DescriptionLength(item.Vector[1]), Days(item.Vector[2]), Hours(item.Vector[3]),
                                            MinSec(item.Vector[4]), MinSec(item.Vector[5]), Follow(item.Vector[6]), Follow(item.Vector[7]), Ratio(item.Vector[8]), Tweets(item.Vector[9]),
                                            TweetsPerDay(item.Vector[10]), AverageLinks(item.Vector[11]), AverageLinks(item.Vector[12]), AverageUsername(item.Vector[13]),
                                            AverageUsername(item.Vector[14]), ChangeRate(item.Vector[15]), item.Sign));
     }
     foreach (var item in data_2)
     {
         Test_Data.Add(new TrainingData(ScreenNameLength(item.Vector[0]), DescriptionLength(item.Vector[1]), Days(item.Vector[2]), Hours(item.Vector[3]),
                                        MinSec(item.Vector[4]), MinSec(item.Vector[5]), Follow(item.Vector[6]), Follow(item.Vector[7]), Ratio(item.Vector[8]), Tweets(item.Vector[9]),
                                        TweetsPerDay(item.Vector[10]), AverageLinks(item.Vector[11]), AverageLinks(item.Vector[12]), AverageUsername(item.Vector[13]),
                                        AverageUsername(item.Vector[14]), ChangeRate(item.Vector[15]), item.Sign));
     }
 }