private static void GetKDDSampleInputData(ref IEnumerable <BatchInputWrapper> trainData, ref IEnumerable <BatchInputWrapper> cvData)
        {
            List <BatchInputWrapper> trainDataList = new List <BatchInputWrapper>();
            List <BatchInputWrapper> cvDataList    = new List <BatchInputWrapper>();

            BatchInputWrapper currentBatch = new BatchInputWrapper(5);

            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 0, 0 }, 4, 9, new float[] { 5, 4, 4, 1, 1 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 1, 1 }, 3, 11, new float[] { 5, 4, 4, 2, 2 }, 1);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 8 }, 0, 11, new float[] { 5, 4, 4, 6, 9 }, 0);
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            currentBatch = new BatchInputWrapper(5);
            //currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 0, 0 }, 4, 9, new float[] { 5, 4, 4, 1, 1 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 10 }, 4, 10, new float[] { 5, 4, 4, 6, 11 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 14 }, 1, 10, new float[] { 5, 4, 4, 6, 15 }, 0);
            currentBatch.SealBatch();
            cvDataList.Add(currentBatch);
            cvData = cvDataList.AsEnumerable();
        }
        static void GetKDDInputData(ref IEnumerable <BatchInputWrapper> trainData, ref IEnumerable <BatchInputWrapper> cvData)
        {
            const string filename = @"D:\vinods\Data\Donation\lrn_data_220k.txt";
            List <Tuple <float[], float, float, float[], float> > formattedData = new List <Tuple <float[], float, float, float[], float> >();

            using (StreamReader sr = new StreamReader(filename))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] data          = line.Split('\t');
                    var      oldState      = new float[] { float.Parse(data[2]), float.Parse(data[3]), float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]) };
                    var      actionIndex   = float.Parse(data[7]);
                    var      reward        = float.Parse(data[8]);
                    var      newState      = new float[] { float.Parse(data[9]), float.Parse(data[10]), float.Parse(data[11]), float.Parse(data[12]), float.Parse(data[13]) };
                    var      isLastEpisode = string.Equals(data[1], "21") ? (float)1 : (float)0;
                    formattedData.Add(Tuple.Create <float[], float, float, float[], float>(oldState, actionIndex, reward, newState, isLastEpisode));
                }
            }

            Random rnd = new Random();

            for (int i = formattedData.Count - 1; i >= 0; i--)
            {
                int swapIndex = rnd.Next(i + 1);
                var tmp       = formattedData.ElementAt(i);
                formattedData[i]         = formattedData.ElementAt(swapIndex);
                formattedData[swapIndex] = tmp;
            }

            int cutIndex       = (int)(formattedData.Count * 0.8);
            int stateDimension = 5;
            // Creating train batches
            BatchInputWrapper        currentBatch  = new BatchInputWrapper(stateDimension);
            List <BatchInputWrapper> trainDataList = new List <BatchInputWrapper>();

            foreach (var item in formattedData.GetRange(0, cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5);
                }
                else
                {
                    currentBatch.SealBatch();
                    trainDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(stateDimension);
                }
            }
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            // Creating test batches
            currentBatch = new BatchInputWrapper(stateDimension);
            List <BatchInputWrapper> testDataList = new List <BatchInputWrapper>();

            foreach (var item in formattedData.GetRange(cutIndex, formattedData.Count - cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5);
                }
                else
                {
                    currentBatch.SealBatch();
                    testDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(stateDimension);
                }
            }
            currentBatch.SealBatch();
            testDataList.Add(currentBatch);
            cvData = testDataList.AsEnumerable();
        }
        static void GetKDDInputData(ref IEnumerable<BatchInputWrapper> trainData, ref IEnumerable<BatchInputWrapper> cvData)
        {
            const string filename = @"D:\vinods\Data\Donation\lrn_data_220k.txt";
            List<Tuple<float[], float, float, float[], float>> formattedData = new List<Tuple<float[], float, float, float[], float>>();
            using (StreamReader sr = new StreamReader(filename))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] data = line.Split('\t');
                    var oldState = new float[] { float.Parse(data[2]), float.Parse(data[3]), float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]) };
                    var actionIndex = float.Parse(data[7]);
                    var reward = float.Parse(data[8]);
                    var newState = new float[] { float.Parse(data[9]), float.Parse(data[10]), float.Parse(data[11]), float.Parse(data[12]), float.Parse(data[13]) };
                    var isLastEpisode = string.Equals(data[1], "21") ? (float)1 : (float)0;
                    formattedData.Add(Tuple.Create<float[], float, float, float[], float>(oldState, actionIndex, reward, newState, isLastEpisode));
                }
            }

            Random rnd = new Random();
            for (int i = formattedData.Count - 1; i >= 0; i--)
            {
                int swapIndex = rnd.Next(i + 1);
                var tmp = formattedData.ElementAt(i);
                formattedData[i] = formattedData.ElementAt(swapIndex);
                formattedData[swapIndex] = tmp;
            }

            int cutIndex = (int)(formattedData.Count * 0.8);
            int stateDimension = 5;
            // Creating train batches
            BatchInputWrapper currentBatch = new BatchInputWrapper(stateDimension);
            List<BatchInputWrapper> trainDataList = new List<BatchInputWrapper>();
            foreach (var item in formattedData.GetRange(0, cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5);
                }
                else
                {
                    currentBatch.SealBatch();
                    trainDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(stateDimension);
                }
            }
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            // Creating test batches
            currentBatch = new BatchInputWrapper(stateDimension);
            List<BatchInputWrapper> testDataList = new List<BatchInputWrapper>();
            foreach (var item in formattedData.GetRange(cutIndex, formattedData.Count - cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5);
                }
                else
                {
                    currentBatch.SealBatch();
                    testDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(stateDimension);
                }
            }
            currentBatch.SealBatch();
            testDataList.Add(currentBatch);
            cvData = testDataList.AsEnumerable();
        }
        private static void GetKDDSampleInputData(ref IEnumerable<BatchInputWrapper> trainData, ref IEnumerable<BatchInputWrapper> cvData)
        {
            List<BatchInputWrapper> trainDataList = new List<BatchInputWrapper>();
            List<BatchInputWrapper> cvDataList = new List<BatchInputWrapper>();

            BatchInputWrapper currentBatch = new BatchInputWrapper(5);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 0, 0 }, 4, 9, new float[] { 5, 4, 4, 1, 1 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 1, 1 }, 3, 11, new float[] { 5, 4, 4, 2, 2 }, 1);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 8 }, 0, 11, new float[] { 5, 4, 4, 6, 9 }, 0);
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            currentBatch = new BatchInputWrapper(5);
            //currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 0, 0 }, 4, 9, new float[] { 5, 4, 4, 1, 1 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 10 }, 4, 10, new float[] { 5, 4, 4, 6, 11 }, 0);
            currentBatch.AddStateActionRewardNewStateIsLastEpisodeData(new float[] { 5, 4, 4, 6, 14 }, 1, 10, new float[] { 5, 4, 4, 6, 15 }, 0);
            currentBatch.SealBatch();
            cvDataList.Add(currentBatch);
            cvData = cvDataList.AsEnumerable();
        }