Example #1
0
        public void LoadDefaultParams()
        {
            string kn = ConfigReader.Read("KNeighbors");

            if (kn != null)
            {
                KNeighbors = int.Parse(kn);
            }
            Prms.Add("KNeighbors", KNeighbors);

            string pw = ConfigReader.Read("Pow");

            if (pw != null)
            {
                Pow = double.Parse(pw.Replace(',', '.'), CultureInfo.InvariantCulture);
            }
            Prms.Add("Pow", Pow);

            string nofs = ConfigReader.Read("NeighborsOffset");

            if (nofs != null)
            {
                NeighborsOffset = int.Parse(nofs);
            }
            Prms.Add("NeighborsOffset", NeighborsOffset);

            string ilen = ConfigReader.Read("InfoLength");

            if (ilen != null)
            {
                InfoLength = int.Parse(ilen);
            }
            Prms.Add("InfoLength", InfoLength);
        }
Example #2
0
            public double[] GetDerivative(double[] x)
            {
                if (Derivatives != null)
                {
                    return(Derivatives(x, Prms));
                }

                var derivative = new double[Length];
                var f0         = Formula(x, Prms);

                for (int j = 0; j < Length; j++)
                {
                    for (int i = 0; i < steps.Length; i++)
                    {
                        var pTemp = Prms.ToArray();//値渡しでコピー
                        pTemp[j]     += steps[i];
                        derivative[j] = (Formula(x, pTemp) - f0) / steps[i];
                        if (derivative[j] != 0)
                        {
                            break;
                        }
                    }
                }
                return(derivative);
            }
Example #3
0
        public IEnumerable <IScnPrm> GetAllParams()
        {
            var res = Prms.Select(prm => prm);

            foreach (var child in Children)
            {
                res = res.Concat(child.GetAllParams());
            }
            return(res);
        }
Example #4
0
 public void RemoveParam(IScnPrm prm)
 {
     if (Prms.Contains(prm))
     {
         Prms.Remove(prm);
         prm.GetVal = null;
         prm.SetVal = null;
         prm.MyDiff = null;
     }
 }
Example #5
0
        public IEnumerable <IScnPrm> GetDiffPrms()
        {
            var chldrenDiffs = Enumerable.Empty <IScnPrm>();

            foreach (var ch in Children)
            {
                chldrenDiffs = chldrenDiffs.Concat(ch.GetDiffPrms());
            }
            return(Prms.Where(a => a.MyDiff != null).Concat(chldrenDiffs));
        }
Example #6
0
        public int AddParam(IScnPrm prm)
        {
            if (!Prms.Contains(prm))
            {
                if (prm.Owner != null && prm.Owner != this)
                {
                    prm.Owner.RemoveParam(prm);
                }

                Prms.Add(prm);
                prm.Owner = this;
            }
            return(Prms.Count);
        }
Example #7
0
        public bool SetDiff(IScnPrm prm, Func <double, double> dPrmdtF, string dname = "")
        {
            if (!Prms.Contains(prm))
            {
                return(false);
            }
            var dprm = new ScnPrm();

            dprm.GetVal = new Func <double, double>(dPrmdtF);

            bool newname = dname == "";

            if (!newname)
            {
                dprm.Name = dname;
            }
            AddDiffPropToParam(prm, dprm, getNewName: newname);
            return(true);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public CreateAttributeDialog(List<dynamic> existingKeys, bool enableEditableCheckBox, bool createKey, bool stringKeyOnly = true)
        ///
        /// \brief Constructor.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 09/05/2017
        ///
        /// \brief #### Description.
        ///
        /// \param existingKeys           (List&lt;dynamic&gt;) - The existing keys (for avoiding duplicate keys).
        /// \param enableEditableCheckBox (bool) - true to enable, false to disable the editable check box.
        /// \param createKey              (bool) - true to create key for the attribute.
        /// \param stringKeyOnly          (Optional)  (bool) - true to string key only.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public CreateAttributeDialog(ElementWindow callingWindow, Prms prms)
        {
            this.prms          = prms;
            this.callingWindow = callingWindow;
            InitializeComponent();
            if (!prms.createKey)
            {
                DockPanel_Key.Visibility            = Visibility.Collapsed;
                Label_SelectAttributeKey.Visibility = Visibility.Collapsed;
            }
            else
            {
                InitKeyComboBoxes();
            }
            FillEndInputOperationsListBox();
            FillInputFieldListBox();
            FillTypesListBox();
            CheckBox_Edditable.IsEnabled = prms.enableEditableCheckBox;
        }
Example #9
0
 public virtual void Dispose()
 {
     DiffArr = null;
     Prms.Clear();
     Prms = null;
     foreach (var ch in Children)
     {
         ch.Dispose();
     }
     Children.Clear();
     Children = null;
     AllParamsNames.Clear();
     AllParamsNames = null;
     Laws.Clear();
     SynchMeBefore          = null;
     SynchMeAfter           = null;
     RebuildStructureAction = null;
     FlagDict.Clear();
     FlagDict = null;
 }
Example #10
0
 public void AddDiffPropToParam(IScnPrm prm, IScnPrm dPrmDt, bool removeOldDt = true, bool getNewName = false)
 {
     if (!Prms.Contains(prm))
     {
         AddParam(prm);
     }
     if (removeOldDt && prm.MyDiff != null && Prms.Contains(prm.MyDiff))
     {
         Prms.Remove(prm.MyDiff);
     }
     if (getNewName)
     {
         dPrmDt.Name = prm.Name + "'";
     }
     prm.MyDiff = dPrmDt;
     if (dPrmDt.Owner == null)
     {
         AddParam(dPrmDt);
     }
 }
Example #11
0
        public IScnPrm FindParam(string paramName)
        {
            var reg = new Regex("\\b" + paramName, RegexOptions.IgnoreCase);

            return(Prms.Where(elem => reg.IsMatch(elem.Name)).FirstOrDefault());
        }
Example #12
0
 public IEnumerable <IScnPrm> GetDiffPrms()
 {
     return(Prms.Where(a => a.MyDiff != null));
 }
Example #13
0
        /// <summary>
        /// Default parameters for random-forest algorithm
        /// </summary>
        private void LoadDefaultParams()
        {
            string rfc = ConfigReader.Read("RfCoeff");

            if (rfc != null)
            {
                RfCoeff = double.Parse(rfc.Replace(',', '.'), CultureInfo.InvariantCulture);
            }
            Prms.Add("RfCoeff", RfCoeff);

            string bifs = ConfigReader.Read("BatchesInFirstStep");

            if (bifs != null)
            {
                BatchesInFirstStep = int.Parse(bifs);
            }
            Prms.Add("BatchesInFirstStep", BatchesInFirstStep);

            string biss = ConfigReader.Read("BatchesInSecondStep");

            if (biss != null)
            {
                BatchesInSecondStep = int.Parse(biss);
            }
            Prms.Add("BatchesInSecondStep", BatchesInSecondStep);

            string tib = ConfigReader.Read("TreesInBatch");

            if (tib != null)
            {
                TreesInBatch = int.Parse(tib);
            }
            Prms.Add("TreesInBatch", TreesInBatch);

            string tbf = ConfigReader.Read("BatchesInBruteForce");

            if (tbf != null)
            {
                BatchesInBruteForce = int.Parse(tbf);
            }
            Prms.Add("BatchesInBruteForce", BatchesInBruteForce);

            string lfsb = ConfigReader.Read("IsLoadFirstStepBatches");

            if (lfsb != null)
            {
                IsLoadFirstStepBatches = bool.Parse(lfsb);
            }
            Prms.Add("IsLoadFirstStepBatches", IsLoadFirstStepBatches);

            string op = ConfigReader.Read("OutliersPrct");

            if (op != null)
            {
                OutliersPrct = double.Parse(op.Replace(',', '.'), CultureInfo.InvariantCulture);
            }
            Prms.Add("OutliersPrct", OutliersPrct);

            string so = ConfigReader.Read("IndexSortOrder");

            if (so != null)
            {
                IndexSortOrder = so;
            }
            Prms.Add("IndexSortOrder", IndexSortOrder);

            string st = ConfigReader.Read("IsSaveTrees");

            if (st != null)
            {
                IsSaveTrees = bool.Parse(st);
            }
            Prms.Add("IsSaveTrees", IsSaveTrees);

            string vcf = ConfigReader.Read("VarsCoeff");

            if (vcf != null)
            {
                VarsCoeff = double.Parse(vcf.Replace(',', '.'), CultureInfo.InvariantCulture);
            }
            Prms.Add("VarsCoeff", VarsCoeff);

            string ubt = ConfigReader.Read("UseBatchLogit");

            if (ubt != null)
            {
                UseBatchLogit = bool.Parse(ubt);
            }
            Prms.Add("UseBatchLogit", UseBatchLogit);
        }