public void SetValidateData(Random rSeed) { Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); int seperator = Convert.ToInt32(Math.Floor(Convert.ToDecimal(Cross_Validate_Data.Count) / 5M)); Cross_1 = Cross_Validate_Data.GetRange(0, seperator); Cross_2 = Cross_Validate_Data.GetRange(seperator, seperator); Cross_3 = Cross_Validate_Data.GetRange(2 * seperator, seperator); Cross_4 = Cross_Validate_Data.GetRange(3 * seperator, seperator); Cross_5 = Cross_Validate_Data.GetRange(4 * seperator, Cross_Validate_Data.Count - (4 * seperator)); }
public void SetValidateData(StreamReader reader, StreamReader reader_2, Random rSeed) { reader.DiscardBufferedData(); reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); string line; while ((line = reader.ReadLine()) != null) { int Sign; double[] Vector = new double[16]; string[] splitstring = line.Split(); if (splitstring.First().First() == '1') { Sign = 1; } else { Sign = 0; } foreach (var item in splitstring) { if (item.Contains(":")) { string[] s = item.Split(':'); Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]); } } Cross_Validate_Data.Add(new Entry(Sign, Vector)); } 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[16]; string[] splitstring = line2.Split(); if (splitstring.First().First() == '1') { Sign = 1; } else { Sign = 0; } foreach (var item in splitstring) { if (item.Contains(":")) { string[] s = item.Split(':'); Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]); } } Cross_Validate_Data.Add(new Entry(Sign, Vector)); } Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); int seperator = Convert.ToInt32(Math.Floor(Convert.ToDecimal(Cross_Validate_Data.Count) / 5M)); Cross_1 = Cross_Validate_Data.GetRange(0, seperator); Cross_2 = Cross_Validate_Data.GetRange(seperator, seperator); Cross_3 = Cross_Validate_Data.GetRange(2 * seperator, seperator); Cross_4 = Cross_Validate_Data.GetRange(3 * seperator, seperator); Cross_5 = Cross_Validate_Data.GetRange(4 * seperator, Cross_Validate_Data.Count - (4 * seperator)); }
public void SetValidateData(StreamReader train, StreamReader test, StreamReader train_ID, StreamReader test_ID, Random rSeed) { train.DiscardBufferedData(); train.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); train_ID.DiscardBufferedData(); train_ID.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); string entry; string ids; while ((entry = train.ReadLine()) != null && (ids = train_ID.ReadLine()) != null) { int Sign; double[] Vector = new double[17]; string[] splitstring = entry.Split(); if (splitstring.First().First() == '1') { Sign = 1; } else { Sign = 0; } foreach (var item in splitstring) { if (item.Contains(":")) { string[] s = item.Split(':'); Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]); } } ReTweets v = ReTweet.Where(t => t.ID == Convert.ToInt32(ids)).FirstOrDefault(); if (v != null) { Vector[16] = v.ReTweet; } //Post p = Post.Where(t => t.ID == Convert.ToInt32(ids)).FirstOrDefault(); //if (p != null) //{ // Vector[17] = p.post; //} Cross_Validate_Data.Add(new Entry(Sign, Vector)); } test.DiscardBufferedData(); test.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); test_ID.DiscardBufferedData(); test_ID.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); string entry2; string ids2; while ((entry2 = test.ReadLine()) != null && (ids2 = test_ID.ReadLine()) != null) { int Sign; double[] Vector = new double[17]; string[] splitstring = entry2.Split(); if (splitstring.First().First() == '1') { Sign = 1; } else { Sign = 0; } foreach (var item in splitstring) { if (item.Contains(":")) { string[] s = item.Split(':'); Vector[Convert.ToInt32(s[0]) - 1] = Convert.ToDouble(s[1]); } } ReTweets v = ReTweet.Where(t => t.ID == Convert.ToInt32(ids2)).FirstOrDefault(); if (v != null) { Vector[16] = v.ReTweet; } //Post p = Post.Where(t => t.ID == Convert.ToInt32(ids2)).FirstOrDefault(); //if (p != null) //{ // Vector[17] = p.post; //} Cross_Validate_Data.Add(new Entry(Sign, Vector)); } Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); Cross_Validate_Data = Cross_Validate_Data.OrderBy(i => rSeed.Next()).ToList(); int seperator = Convert.ToInt32(Math.Floor(Convert.ToDecimal(Cross_Validate_Data.Count) / 5M)); Cross_1 = Cross_Validate_Data.GetRange(0, seperator); Cross_2 = Cross_Validate_Data.GetRange(seperator, seperator); Cross_3 = Cross_Validate_Data.GetRange(2 * seperator, seperator); Cross_4 = Cross_Validate_Data.GetRange(3 * seperator, seperator); Cross_5 = Cross_Validate_Data.GetRange(4 * seperator, Cross_Validate_Data.Count - (4 * seperator)); //var maxx = Cross_Validate_Data.Select(x => x.Vector[15]).ToList().OrderBy(m => m); //var max1 = Cross_Validate_Data.Select(x => x.Vector[15]).ToList().OrderByDescending(m => m); //var max2 = Cross_Validate_Data.Select(x => x.Vector[14]).ToList().OrderBy(m => m); //var max3 = Cross_Validate_Data.Select(x => x.Vector[14]).ToList().OrderByDescending(m => m); //var max4 = Cross_Validate_Data.Select(x => x.Vector[13]).ToList().OrderBy(m => m); //var max5 = Cross_Validate_Data.Select(x => x.Vector[13]).ToList().OrderByDescending(m => m); //var max6 = Cross_Validate_Data.Select(x => x.Vector[12]).ToList().OrderBy(m => m); //var max7 = Cross_Validate_Data.Select(x => x.Vector[12]).ToList().OrderByDescending(m => m); //var max8 = Cross_Validate_Data.Select(x => x.Vector[11]).ToList().OrderBy(m => m); //var max9 = Cross_Validate_Data.Select(x => x.Vector[11]).ToList().OrderByDescending(m => m); //var max10 = Cross_Validate_Data.Select(x => x.Vector[10]).ToList().OrderBy(m => m); //var max11 = Cross_Validate_Data.Select(x => x.Vector[10]).ToList().OrderByDescending(m => m); //var max12 = Cross_Validate_Data.Select(x => x.Vector[9]).ToList().OrderBy(m => m); //var max13 = Cross_Validate_Data.Select(x => x.Vector[9]).ToList().OrderByDescending(m => m); //var max14 = Cross_Validate_Data.Select(x => x.Vector[8]).ToList().OrderBy(m => m); //var max15 = Cross_Validate_Data.Select(x => x.Vector[8]).ToList().OrderByDescending(m => m); //var max16 = Cross_Validate_Data.Select(x => x.Vector[7]).ToList().OrderBy(m => m); //var max17 = Cross_Validate_Data.Select(x => x.Vector[7]).ToList().OrderByDescending(m => m); //var max18 = Cross_Validate_Data.Select(x => x.Vector[6]).ToList().OrderBy(m => m); //var max19 = Cross_Validate_Data.Select(x => x.Vector[6]).ToList().OrderByDescending(m => m); //var max20 = Cross_Validate_Data.Select(x => x.Vector[5]).ToList().OrderBy(m => m); //var max21 = Cross_Validate_Data.Select(x => x.Vector[5]).ToList().OrderByDescending(m => m); //var max22 = Cross_Validate_Data.Select(x => x.Vector[4]).ToList().OrderBy(m => m); //var max23 = Cross_Validate_Data.Select(x => x.Vector[4]).ToList().OrderByDescending(m => m); //var max111 = Cross_Validate_Data.Select(x => x.Vector[3]).ToList().OrderBy(m => m); //var max1111 = Cross_Validate_Data.Select(x => x.Vector[3]).ToList().OrderByDescending(m => m); //var max1112 = Cross_Validate_Data.Select(x => x.Vector[2]).ToList().OrderBy(m => m); //var max1235 = Cross_Validate_Data.Select(x => x.Vector[2]).ToList().OrderByDescending(m => m); //var max567 = Cross_Validate_Data.Select(x => x.Vector[1]).ToList().OrderBy(m => m); //var max1789 = Cross_Validate_Data.Select(x => x.Vector[1]).ToList().OrderByDescending(m => m); //var max09 = Cross_Validate_Data.Select(x => x.Vector[0]).ToList().OrderBy(m => m); //var max189 = Cross_Validate_Data.Select(x => x.Vector[0]).ToList().OrderByDescending(m => m); }