示例#1
0
 public void Bind(object pArgument)
 {
     if (pArgument is randomForestArguments)
     {
         randomForestArguments arg = (randomForestArguments)pArgument;
         inrsBandsCoef = arg.InRasterCoefficients;
         //coefRaster = arg.RasterUtility.createRaster(inrsBandsCoef);
         outrs = arg.OutRaster;
         xVls  = new double[((IRasterBandCollection)inrsBandsCoef).Count];
         Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString());
         df = arg.RandomForestModel;
         myFunctionHelper.Bind(outrs);
         myFunctionHelperCoef.Bind(inrsBandsCoef);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype  = myRasterInfo.PixelType;
         myValidFlag  = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: randomForestArguments");
     }
 }
示例#2
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string depFld   = cmbDepedent.Text;
            string outP     = txtOutputPath.Text;
            int    trees    = System.Convert.ToInt32(nudTrees.Value);
            double ratio    = System.Convert.ToDouble(nudratio.Value);
            int    split    = System.Convert.ToInt32(nudSplit.Value);

            if (smpFtrNm == null || smpFtrNm == "")
            {
                MessageBox.Show("You must select a feature Class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (depFld == null || depFld == "")
            {
                MessageBox.Show("You must select a dependent field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outP == null || outP == "")
            {
                MessageBox.Show("You must select an output model path", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <string> lstInd = new List <string>();

            for (int i = 0; i < lstIndependent.Items.Count; i++)
            {
                string s = lstIndependent.Items[i].ToString();
                lstInd.Add(s);
            }
            if (lstInd.Count < 1)
            {
                MessageBox.Show("You must select at least one independent field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            try
            {
                Statistics.ModelHelper.runProgressBar("Running Random Forest");
                if (!chbReg.Checked && !lstCategoricalFlds.Contains(depFld))
                {
                    lstCategoricalFlds.Add(depFld);
                }
                ITable ftrCls = ftrDic[smpFtrNm];
                Statistics.dataPrepRandomForest rf = null;
                if (split > 0)
                {
                    rf = new Statistics.dataPrepRandomForest(ftrCls, new string[] { depFld }, lstInd.ToArray(), lstCategoricalFlds.ToArray(), trees, ratio, split, chbVI.Checked, qf);
                }
                else
                {
                    rf = new Statistics.dataPrepRandomForest(ftrCls, new string[] { depFld }, lstInd.ToArray(), lstCategoricalFlds.ToArray(), trees, ratio, chbVI.Checked, qf);
                }
                rf.writeModel(outP);
                rf.getReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string smpFtrNm = cmbSampleFeatureClass.Text;
     string depFld = cmbDepedent.Text;
     string outP = txtOutputPath.Text;
     int trees = System.Convert.ToInt32(nudTrees.Value);
     double ratio = System.Convert.ToDouble(nudratio.Value);
     int split = System.Convert.ToInt32(nudSplit.Value);
     if (smpFtrNm == null || smpFtrNm == "")
     {
         MessageBox.Show("You must select a feature Class","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (depFld == null || depFld == "")
     {
         MessageBox.Show("You must select a dependent field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (outP == null || outP == "")
     {
         MessageBox.Show("You must select an output model path", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     List<string> lstInd = new List<string>();
     for (int i = 0; i < lstIndependent.Items.Count; i++)
     {
         string s = lstIndependent.Items[i].ToString();
         lstInd.Add(s);
     }
     if (lstInd.Count < 1)
     {
         MessageBox.Show("You must select at least one independent field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     this.Visible = false;
     try
     {
         Statistics.ModelHelper.runProgressBar("Running Random Forest");
         if (!chbReg.Checked && !lstCategoricalFlds.Contains(depFld))
         {
             lstCategoricalFlds.Add(depFld);
         }
         ITable ftrCls = ftrDic[smpFtrNm];
         Statistics.dataPrepRandomForest rf = null;
         if (split > 0)
         {
             rf = new Statistics.dataPrepRandomForest(ftrCls, new string[] { depFld }, lstInd.ToArray(), lstCategoricalFlds.ToArray(), trees, ratio, split,chbVI.Checked,qf);
         }
         else
         {
             rf = new Statistics.dataPrepRandomForest(ftrCls, new string[] { depFld }, lstInd.ToArray(), lstCategoricalFlds.ToArray(), trees, ratio,chbVI.Checked,qf);
         }
         rf.writeModel(outP);
         rf.getReport();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         Statistics.ModelHelper.closeProgressBar();
         this.Close();
     }
 }