public bool MatrixCal(List <string> testset, List <string> trainset, int order)
        {
            if (testset.Count > 0)
            {
                FreeContainer.FreeTable(HMatrix);
                SpecAngel sa = new SpecAngel();
                WaveShape ws = new WaveShape();
                InputData id = new InputData();
                for (int i = 0; i < trainset.Count + 1; i++)
                {
                    if (i == 0)
                    {
                        DataColumn dc = new DataColumn(" ");
                        HMatrix.Columns.Add(dc);
                    }
                    else
                    {
                        DataColumn dc = new DataColumn(trainset[i - 1]);
                        HMatrix.Columns.Add(dc);
                    }
                }
                for (int i = 0; i < testset.Count; i++)
                {
                    DataRow dr = HMatrix.NewRow();
                    dr[0] = testset[i];
                    DataTable dt1 = id.InputCSV(Config.uksoilfolder + @"\" + testset[i] + ".csv");
                    for (int j = 0; j < trainset.Count; j++)
                    {
                        AuxiliaryFunc.percent = Convert.ToInt32((i + 1) * (j + 1) / testset.Count / trainset.Count * 95);
                        DataTable dt2 = id.InputCSV(Config.soilfolder + @"\" + trainset[i] + ".csv");
                        switch (order)
                        {
                        case 0: dr[j + 1] = sa.SAcal(dt1, dt2).ToString(); break;

                        case 1: dr[j + 1] = ws.WaveCal(dt1, dt2).ToString(); break;

                        default: break;
                        }
                    }
                    AuxiliaryFunc.percent += Convert.ToDouble(i) / Convert.ToDouble(testset.Count) * 90;
                    HMatrix.Rows.Add(dr);
                }
                return(true);
            }
            else
            {
                MessageBox.Show("测试集为空!");
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 计算非特征值距离矩阵
        /// </summary>
        /// <param name="testset">测试集剖面</param>
        /// <param name="trainset">训练集剖面</param>
        /// <param name="order"></param>
        /// <returns></returns>
        public bool NormalMatrix(List <string> testset, List <string> trainset, int order)
        {
            FreeContainer.FreeTable(Matrix);
            SpecAngel sa = new SpecAngel();
            WaveShape ws = new WaveShape();
            InputData id = new InputData();

            for (int i = 0; i < trainset.Count + 1; i++)
            {
                if (i == 0)
                {
                    DataColumn dc = new DataColumn();
                    Matrix.Columns.Add(dc);
                }
                else
                {
                    DataColumn dc = new DataColumn(trainset[i - 1]);
                    Matrix.Columns.Add(dc);
                }
            }
            for (int i = 0; i < testset.Count; i++)
            {
                DataRow dr = Matrix.NewRow();
                dr[0] = testset[i];
                DataTable dt1 = id.InputCSV(Config.uksoilfolder + "\\" + testset[i].Substring(1, testset[i].Length - 2) + ".csv");
                for (int j = 0; j < trainset.Count; j++)
                {
                    DataTable dt2 = id.InputCSV(Config.soilfolder + "\\" + trainset[j].Substring(1, trainset[j].Length - 2) + ".csv");
                    if (dt1.Rows.Count > 0 && dt2.Rows.Count > 0)//防止剖面缺失
                    {
                        switch (order)
                        {
                        case 0: dr[j + 1] = sa.SAcal(dt1, dt2).ToString(); break;

                        case 1: dr[j + 1] = ws.WaveCal(dt1, dt2).ToString(); break;

                        default: break;
                        }
                    }
                    else
                    {
                        dr[j + 1] = 9999.ToString();//9999表示剖面缺失
                    }
                }
                Matrix.Rows.Add(dr);
            }
            return(true);
        }