public List <DataSeq> GetmsrTrainingData(double scale)
        {
            List <DataSeq> result = new List <DataSeq>();
            int            index  = 0;

            for (int i = 0; i < (int)(msrData.Count * scale); i++)
            {
                DataSeq tempSeq = new DataSeq();
                for (int j = 0; j < msrData[i].Count; j++)
                {
                    List <int> temp        = new List <int>();
                    List <int> bigramtemp1 = new List <int>();
                    List <int> bigramtemp2 = new List <int>();
                    List <int> bigramtemp3 = new List <int>();
                    List <int> bigramtemp4 = new List <int>();



                    bigramtemp1.Add(j - 2 >= 0 ? msrDatabigram1[i][j - 2] : 1955);
                    bigramtemp1.Add(j - 1 >= 0 ? msrDatabigram1[i][j - 1] : 1955);
                    bigramtemp1.Add(msrDatabigram1[i][j]);
                    bigramtemp1.Add(j + 1 < msrDatabigram1[i].Count ? msrDatabigram1[i][j + 1] : 1956);
                    bigramtemp1.Add(j + 2 < msrDatabigram1[i].Count ? msrDatabigram1[i][j + 2] : 1956);

                    bigramtemp2.Add(j - 2 >= 0 ? msrDatabigram2[i][j - 2] : 1955);
                    bigramtemp2.Add(j - 1 >= 0 ? msrDatabigram2[i][j - 1] : 1955);
                    bigramtemp2.Add(msrDatabigram2[i][j]);
                    bigramtemp2.Add(j + 1 < msrDatabigram2[i].Count ? msrDatabigram2[i][j + 1] : 1956);
                    bigramtemp2.Add(j + 2 < msrDatabigram2[i].Count ? msrDatabigram2[i][j + 2] : 1956);

                    bigramtemp3.Add(j - 2 >= 0 ? msrDatabigram3[i][j - 2] : 1955);
                    bigramtemp3.Add(j - 1 >= 0 ? msrDatabigram3[i][j - 1] : 1955);
                    bigramtemp3.Add(msrDatabigram3[i][j]);
                    bigramtemp3.Add(j + 1 < msrDatabigram3[i].Count ? msrDatabigram3[i][j + 1] : 1956);
                    bigramtemp3.Add(j + 2 < msrDatabigram3[i].Count ? msrDatabigram3[i][j + 2] : 1956);

                    bigramtemp4.Add(j - 2 >= 0 ? msrDatabigram4[i][j - 2] : 1955);
                    bigramtemp4.Add(j - 1 >= 0 ? msrDatabigram4[i][j - 1] : 1955);
                    bigramtemp4.Add(msrDatabigram4[i][j]);
                    bigramtemp4.Add(j + 1 < msrDatabigram4[i].Count ? msrDatabigram4[i][j + 1] : 1956);
                    bigramtemp4.Add(j + 2 < msrDatabigram4[i].Count ? msrDatabigram4[i][j + 2] : 1956);


                    temp.Add(j - 2 >= 0 ? msrData[i][j - 2] : 1955);
                    temp.Add(j - 1 >= 0 ? msrData[i][j - 1] : 1955);
                    temp.Add(msrData[i][j]);
                    temp.Add(j + 1 < msrData[i].Count ? msrData[i][j + 1] : 1956);
                    temp.Add(j + 2 < msrData[i].Count ? msrData[i][j + 2] : 1956);
                    tempSeq.datasteps.Add(new DataStep(temp, bigramtemp1, bigramtemp2, bigramtemp3, bigramtemp4, msrLabel[i][j], msrData[i][j]));
                    index++;
                }
                result.Add(tempSeq);
            }
            return(result);
        }
        public List <DataSeq> GetDev( )
        {
            List <DataSeq> result = new List <DataSeq>();
            int            index  = 0;

            for (int i = (int)(trainData.Count * Global.trainingScale * 0.9); i < (int)(trainData.Count * Global.trainingScale); i++)
            {
                DataSeq tempSeq = new DataSeq();
                for (int j = 0; j < trainData[i].Count; j++)
                {
                    List <int> temp        = new List <int>();
                    List <int> bigramtemp1 = new List <int>();
                    List <int> bigramtemp2 = new List <int>();
                    List <int> bigramtemp3 = new List <int>();
                    List <int> bigramtemp4 = new List <int>();



                    bigramtemp1.Add(j - 2 >= 0 ? trainDatabigram1[i][j - 2] : 1955);
                    bigramtemp1.Add(j - 1 >= 0 ? trainDatabigram1[i][j - 1] : 1955);
                    bigramtemp1.Add(trainDatabigram1[i][j]);
                    bigramtemp1.Add(j + 1 < trainDatabigram1[i].Count ? trainDatabigram1[i][j + 1] : 1956);
                    bigramtemp1.Add(j + 2 < trainDatabigram1[i].Count ? trainDatabigram1[i][j + 2] : 1956);

                    bigramtemp2.Add(j - 2 >= 0 ? trainDatabigram2[i][j - 2] : 1955);
                    bigramtemp2.Add(j - 1 >= 0 ? trainDatabigram2[i][j - 1] : 1955);
                    bigramtemp2.Add(trainDatabigram2[i][j]);
                    bigramtemp2.Add(j + 1 < trainDatabigram2[i].Count ? trainDatabigram2[i][j + 1] : 1956);
                    bigramtemp2.Add(j + 2 < trainDatabigram2[i].Count ? trainDatabigram2[i][j + 2] : 1956);

                    bigramtemp3.Add(j - 2 >= 0 ? trainDatabigram3[i][j - 2] : 1955);
                    bigramtemp3.Add(j - 1 >= 0 ? trainDatabigram3[i][j - 1] : 1955);
                    bigramtemp3.Add(trainDatabigram3[i][j]);
                    bigramtemp3.Add(j + 1 < trainDatabigram3[i].Count ? trainDatabigram3[i][j + 1] : 1956);
                    bigramtemp3.Add(j + 2 < trainDatabigram3[i].Count ? trainDatabigram3[i][j + 2] : 1956);

                    bigramtemp4.Add(j - 2 >= 0 ? trainDatabigram4[i][j - 2] : 1955);
                    bigramtemp4.Add(j - 1 >= 0 ? trainDatabigram4[i][j - 1] : 1955);
                    bigramtemp4.Add(trainDatabigram4[i][j]);
                    bigramtemp4.Add(j + 1 < trainDatabigram4[i].Count ? trainDatabigram4[i][j + 1] : 1956);
                    bigramtemp4.Add(j + 2 < trainDatabigram4[i].Count ? trainDatabigram4[i][j + 2] : 1956);


                    temp.Add(j - 2 >= 0 ? trainData[i][j - 2] : 1955);
                    temp.Add(j - 1 >= 0 ? trainData[i][j - 1] : 1955);
                    temp.Add(trainData[i][j]);
                    temp.Add(j + 1 < trainData[i].Count ? trainData[i][j + 1] : 1956);
                    temp.Add(j + 2 < trainData[i].Count ? trainData[i][j + 2] : 1956);
                    tempSeq.datasteps.Add(new DataStep(temp, bigramtemp1, bigramtemp2, bigramtemp3, bigramtemp4, trainLabel[i][j], trainData[i][j]));
                    index++;
                }
                result.Add(tempSeq);
            }
            return(result);
        }
Exemple #3
0
        public static List <DataSeq> shuffle(List <DataSeq> list)
        {
            Random         rand         = new Random();
            List <DataSeq> returnObject = new List <DataSeq>();

            for (int i = 0; i < list.Count; i++)
            {
                int length = list[i].datasteps.Count;
                int index  = 0;

                //while (index < length)
                //{
                //DataSeq temp = new DataSeq();
                //int dim = 0;
                ////if (random() == 0)
                ////{
                ////    dim = 1;
                ////}
                ////else
                ////{
                ////    dim = 2;
                ////}
                // dim = length;
                //for (int k = 0; k < dim && index < length; k++, index++)
                //{
                //    temp.Add(list[i]);
                //}
                returnObject.Add(list[i]);
                //}
            }
            //for (int i = 0; i < list.Count; i++)
            //{
            //    for(int j=0;j<list[i].datasteps.Count;j++){
            //        returnObject.Add(list[i].datasteps[j]);
            //    }
            //}
            int n = returnObject.Count;

            while (n > 1)
            {
                n--;
                int     k     = rand.Next(n + 1);
                DataSeq value = returnObject[k];
                returnObject[k] = returnObject[n];
                returnObject[n] = value;
            }
            return(returnObject);
        }
Exemple #4
0
        public List <DataSeq> GetTestData(double scale = 1)
        {
            List <DataSeq> result = new List <DataSeq>();
            int            index  = 0;

            for (int i = 0; i < (int)testData.Count * scale; i++)
            {
                DataSeq tempSeq = new DataSeq();
                for (int j = 0; j < testData[i].Count; j++)
                {
                    List <int> temp = new List <int>();
                    temp.Add(j - 2 >= 0 ? testData[i][j - 2] : num - 1);
                    temp.Add(j - 1 >= 0 ? testData[i][j - 1] : num - 1);
                    temp.Add(testData[i][j]);
                    temp.Add(j + 1 < testData[i].Count ? testData[i][j + 1] : num - 1);
                    temp.Add(j + 2 < testData[i].Count ? testData[i][j + 2] : num - 1);
                    tempSeq.datasteps.Add(new DataStep(temp, testLabel[i][j], testData[i][j]));
                    index++;
                }
                result.Add(tempSeq);
            }
            return(result);
        }
Exemple #5
0
        //public StreamWriter sw;
        //public string write_string="";

        public param(DataSeq seq = null)
        {
            this.seq = seq;
            datastep = seq.datasteps;
        }