示例#1
0
 new public void buildModel(string modelPath)
 {
     outmodelpath = modelPath;
     using (System.IO.StreamReader sr = new System.IO.StreamReader(outmodelpath))
     {
         dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
         if (mType != dataPrepBase.modelTypes.PAIREDTTEST)
         {
             System.Windows.Forms.MessageBox.Show("Not a PairedTTest Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
             return;
         }
         inpath             = sr.ReadLine();
         StrataField        = sr.ReadLine();
         VariableFieldNames = sr.ReadLine().Split(new char[] { ',' });
         n   = System.Convert.ToInt32(sr.ReadLine());
         lbl = sr.ReadLine().Split(new char[] { ',' }).ToList();
         int[] sCnt = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToInt32(s)).ToArray();
         cateDic.Clear();
         for (int i = 0; i < lbl.Count; i++)
         {
             cateDic.Add(lbl[i], sCnt[i]);
         }
         sumX.Clear();
         sumX2.Clear();
         for (int i = 0; i < lbl.Count; i++)
         {
             sumX.Add((from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray());
             sumX2.Add((from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray());
         }
         sr.Close();
     }
 }
示例#2
0
 public void buildModel(string modelPath)
 {
     outmodelpath = modelPath;
     using (System.IO.StreamReader sr = new System.IO.StreamReader(outmodelpath))
     {
         dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
         if (mType != dataPrepBase.modelTypes.CovCorr)
         {
             cov = new double[1, 1];
             System.Windows.Forms.MessageBox.Show("Not a Variance Covariance Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
             return;
         }
         inpath             = sr.ReadLine();
         VariableFieldNames = sr.ReadLine().Split(new char[] { ',' });
         n        = System.Convert.ToInt32(sr.ReadLine());
         sumClms  = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
         cov      = new double[sumClms.Length, sumClms.Length];
         sumCross = new double[sumClms.Length, sumClms.Length];
         string[] crossStr = sr.ReadLine().Split(new char[] { ',' });
         string[] covStr   = sr.ReadLine().Split(new char[] { ',' });
         for (int i = 0; i < sumClms.Length; i++)
         {
             for (int j = 0; j < sumClms.Length; j++)
             {
                 int indexVl = (i * sumClms.Length) + j;
                 sumCross[i, j] = System.Convert.ToDouble(crossStr[indexVl]);
                 cov[i, j]      = System.Convert.ToDouble(covStr[indexVl]);
             }
         }
         sr.Close();
     }
 }
示例#3
0
        public void buildModel(string modelPath)
        {
            outmodelpath = modelPath;
            using (System.IO.StreamReader sr = new System.IO.StreamReader(outmodelpath))
            {
                dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
                if (mType != dataPrepBase.modelTypes.TTEST)
                {
                    System.Windows.Forms.MessageBox.Show("Not a TTest Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
                inpath             = sr.ReadLine();
                stratafld          = sr.ReadLine();
                VariableFieldNames = sr.ReadLine().Split(new char[] { ',' });
                n      = System.Convert.ToInt32(sr.ReadLine());
                prop   = System.Convert.ToDouble(sr.ReadLine());
                k      = System.Convert.ToInt32(sr.ReadLine());
                lbl    = sr.ReadLine().Split(new char[] { ',' }).ToList();
                kmeans = new KMeans(k);
                KMeansClusterCollection kmeansColl = kmeans.Clusters;
                for (int i = 0; i < k; i++)
                {
                    double[] mns       = (from s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray();
                    string[] covVlsStr = sr.ReadLine().Split(new char[] { ',' });
                    double   p         = System.Convert.ToDouble(sr.ReadLine());
                    double[,] cov = new double[VariableFieldNames.Length, VariableFieldNames.Length];
                    for (int j = 0; j < VariableFieldNames.Length; j++)
                    {
                        for (int l = 0; l < VariableFieldNames.Length; l++)
                        {
                            int indexVl = (j * VariableFieldNames.Length) + l;
                            cov[l, j] = System.Convert.ToDouble(covVlsStr[indexVl]);
                        }
                    }

                    KMeansCluster kc = new KMeansCluster(kmeansColl, i);
                    kc.Mean       = mns;
                    kc.Covariance = cov;
                    kc.Proportion = p;
                }
                sr.Close();
            }
        }
示例#4
0
        public void buildModel(string modelPath)
        {
            outmodelpath = modelPath;
            using (System.IO.StreamReader sr = new System.IO.StreamReader(outmodelpath))
            {
                dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
                if (mType != dataPrepBase.modelTypes.Cluster)
                {
                    System.Windows.Forms.MessageBox.Show("Not a Cluster Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
                cType              = (clusterType)System.Enum.Parse(typeof(clusterType), sr.ReadLine());
                inpath             = sr.ReadLine();
                VariableFieldNames = sr.ReadLine().Split(new char[] { ',' });
                n    = System.Convert.ToInt32(sr.ReadLine());
                prop = System.Convert.ToDouble(sr.ReadLine());
                k    = System.Convert.ToInt32(sr.ReadLine());
                lbl  = sr.ReadLine().Split(new char[] { ',' }).ToList();
                switch (cType)
                {
                case clusterType.KMEANS:
                    setKMeansCluster(sr);
                    break;

                case clusterType.BINARY:
                    setBinaryCluster(sr);
                    break;

                case clusterType.GAUSSIANMIXTURE:
                    setGaussianCluster(sr);
                    break;

                default:
                    break;
                }
                sr.Close();
            }
        }
示例#5
0
 public void buildModel(string modelPath)
 {
     outmodelpath = modelPath;
     using (System.IO.StreamReader sr = new System.IO.StreamReader(outmodelpath))
     {
         dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
         if (mType != dataPrepBase.modelTypes.PCA)
         {
             egVec = new double[1, 1];
             System.Windows.Forms.MessageBox.Show("Not a PCA Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
             return;
         }
         inpath             = sr.ReadLine();
         VariableFieldNames = sr.ReadLine().Split(new char[] { ',' });
         corr       = new double[VariableFieldNames.Length, VariableFieldNames.Length];
         egVec      = new double[VariableFieldNames.Length, VariableFieldNames.Length];
         n          = System.Convert.ToInt32(sr.ReadLine());
         meanVector = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
         stdVector  = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
         string[] corrLg = sr.ReadLine().Split(new char[] { ',' });
         prop  = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
         egVal = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
         string[] egVecLg = sr.ReadLine().Split(new char[] { ',' });
         for (int i = 0; i < VariableFieldNames.Length; i++)
         {
             for (int j = 0; j < VariableFieldNames.Length; j++)
             {
                 int indexVl = (i * VariableFieldNames.Length) + j;
                 corr[i, j]  = System.Convert.ToDouble(corrLg[indexVl]);
                 egVec[i, j] = System.Convert.ToDouble(egVecLg[indexVl]);
             }
         }
         sr.Close();
     }
     pca = PrincipalComponentAnalysis.FromCorrelationMatrix(meanVector, stdVector, corr);
     pca.Compute();
 }
示例#6
0
 private void buildModel(string mdlPath)
 {
     using (System.IO.StreamReader sr = new System.IO.StreamReader(mdlPath))
     {
         dataPrepBase.modelTypes mType = (dataPrepBase.modelTypes)Enum.Parse(typeof(dataPrepBase.modelTypes), sr.ReadLine());
         if (mType != dataPrepBase.modelTypes.KS)
         {
             System.Windows.Forms.MessageBox.Show("Not a KS Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
             return;
         }
         Variables   = sr.ReadLine().Split(new char[] { ',' });
         StrataField = sr.ReadLine();
         Oridinate   = System.Convert.ToBoolean(sr.ReadLine());
         string[] lbl   = sr.ReadLine().Split(new char[] { ',' });
         string[] pArr  = sr.ReadLine().Split(new char[] { ',' });
         string[] sArr  = sr.ReadLine().Split(new char[] { ',' });
         string[] cArr1 = sr.ReadLine().Split(new char[] { ',' });
         string[] cArr2 = sr.ReadLine().Split(new char[] { ',' });
         for (int i = 0; i < lbl.Length; i++)
         {
             string   l  = lbl[i];
             double[] p  = (from string str in pArr[i].Split(new char[] { ';' }) select System.Convert.ToDouble(str)).ToArray();
             double[] s  = (from string str in sArr[i].Split(new char[] { ';' }) select System.Convert.ToDouble(str)).ToArray();
             int      c1 = System.Convert.ToInt32(cArr1[i]);
             int      c2 = System.Convert.ToInt32(cArr2[i]);
             pDic.Add(l, p);
             sDic.Add(l, s);
             cntDic.Add(l, new int[] { c1, c2 });
         }
         double[][] minmax1, minmax2, bp1, bp2;
         for (int i = 0; i < lbl.Length; i++)
         {
             string   l    = lbl[i];
             double[] min1 = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
             double[] max1 = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
             double[] min2 = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
             double[] max2 = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
             minmax1    = new double[2][];
             minmax1[0] = min1;
             minmax1[1] = max1;
             minMaxDic1.Add(l, minmax1);
             minmax2    = new double[2][];
             minmax2[0] = min2;
             minmax2[1] = max2;
             minMaxDic2.Add(l, minmax2);
             bp1 = new double[Variables.Length][];
             bp2 = new double[Variables.Length][];
             for (int j = 0; j < Variables.Length; j++)
             {
                 bp1[j] = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
                 bp2[j] = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToDouble(s)).ToArray();
             }
             binPropDic1.Add(l, bp1);
             binPropDic2.Add(l, bp2);
             int[] clusCnt = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray();
             clusCountDic.Add(l, clusCnt);
             int[] clusSampCnt = (from string s in sr.ReadLine().Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray();
             clusSampleCountDic.Add(l, clusSampCnt);
         }
         pca = new dataPrepPrincipleComponents();
         string pcPath = System.IO.Path.GetDirectoryName(mdlPath) + "\\" + System.IO.Path.GetFileNameWithoutExtension(mdlPath) + "_pca.mdl";
         pca.buildModel(pcPath);
         cluster = new dataPrepClusterKmean();
         string clusterPath = System.IO.Path.GetDirectoryName(mdlPath) + "\\" + System.IO.Path.GetFileNameWithoutExtension(mdlPath) + "_cluster.mdl";
         cluster.buildModel(clusterPath);
         numberOfBins = cluster.Classes;
         sr.Close();
     }
 }
示例#7
0
        public static void getReport(string modelPath, double proportion = 0.1, double alpha = 0.05)
        {
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new Forms.RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Sample size for " + modelPath + " based on variation");
            rp.stepPGBar(50);
            rp.Show();
            dataPrepBase.modelTypes mType = ModelHelper.getModelType(modelPath);
            rp.addMessage("Model Type = " + mType.ToString());
            try
            {
                switch (mType)
                {
                case dataPrepBase.modelTypes.Accuracy:
                    fillAaReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.LinearRegression:
                    fillLrReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.MvlRegression:
                    fillMvrReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.LogisticRegression:
                    fillLogisticReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.PLR:
                    fillPlrReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.CovCorr:
                    fillCovCorr(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.PCA:
                    fillPcaReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.Cluster:
                    fillCluserReport(modelPath, rp, proportion, alpha);
                    break;

                case dataPrepBase.modelTypes.StrataCovCorr:
                    fillStrataReport(modelPath, rp, proportion, alpha);
                    break;

                default:
                    rp.addMessage("Can't estimate sample size for this type of model!");
                    break;
                }
            }
            catch (Exception e)
            {
                rp.addMessage(e.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
            }
        }