Esempio n. 1
0
        void sctrCtxRegResults_Completed(object sender, EventArgs e)
        {
            InvokeOperation <LinRegressionResults> result = (InvokeOperation <LinRegressionResults>)sender;

            if (result.HasError)
            {
                ex = result.Error;
                result.MarkErrorAsHandled();
            }
            //else
            //{
            LinRegressionResults returnedData = ((InvokeOperation <LinRegressionResults>)sender).Value;

            _rresultsCompleted(returnedData, null);
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// Completion for regresion results Table
        /// </summary>
        /// <param name="result"></param>
        /// <param name="e"></param>
        private void GetRegressionResultsCompleted(LinRegressionResults result, Exception e)
        {
            if (e != null)
            {
                NotificationEventArgs <Exception> notification = new NotificationEventArgs <Exception>("", e);
                this.Notify(ErrorNotice, notification);
            }
            else
            {
                this.RegressionResults = result;
                if (this.RegressionResults == null)
                {
                    Exception exp = new Exception(SharedStrings.NO_RECORDS_SELECTED.ToString());

                    this.Notify(ErrorNotice, new NotificationEventArgs <Exception>("", exp));
                }
                else
                {
                    this.Notify(RegressResultsLoadedEvent, new NotificationEventArgs <Exception>());
                }
            }
        }
Esempio n. 3
0
        internal LinRegressionResults FormatLinRegressionResults(LinRegressionResults LinRegressionResults)
        {
            LinRegressionResults.RegressionSumOfSquares = Convert.ToDouble(LinRegressionResults.RegressionSumOfSquares.ToString("F4"));
            LinRegressionResults.RegressionMeanSquare   = Convert.ToDouble(LinRegressionResults.RegressionMeanSquare.ToString("F4"));
            LinRegressionResults.RegressionF            = Convert.ToDouble(LinRegressionResults.RegressionF.ToString("F4"));

            LinRegressionResults.ResidualsSumOfSquares = Convert.ToDouble(LinRegressionResults.ResidualsSumOfSquares.ToString("F4"));
            LinRegressionResults.ResidualsMeanSquare   = Convert.ToDouble(LinRegressionResults.ResidualsMeanSquare.ToString("F4"));

            LinRegressionResults.TotalSumOfSquares = Convert.ToDouble(LinRegressionResults.TotalSumOfSquares.ToString("F4"));

            LinRegressionResults.CorrelationCoefficient = Convert.ToDouble(LinRegressionResults.CorrelationCoefficient.ToString("F2"));


            foreach (var item in LinRegressionResults.Variables)
            {
                item.Coefficient = Convert.ToDouble(item.Coefficient.ToString("F3"));
                item.StdError    = Convert.ToDouble(item.StdError.ToString("F3"));
                item.Ftest       = Convert.ToDouble(item.Ftest.ToString("F4"));
                item.P           = Convert.ToDouble(item.P.ToString("F6"));
            }
            return(LinRegressionResults);
        }
Esempio n. 4
0
        // POST api/<controller>
        public HttpResponseMessage Post([FromBody]      JObject value)
        {
            LinearRegressionDomainService LinearRegressionDomainService = new LinearRegressionDomainService();
            GadgetParameters     GadgetParameters;
            ControllerCommon     CommonClass = new ControllerCommon();
            List <EwavRule_Base> Rules       = new List <EwavRule_Base>();

            JObject gadgetJSON = (JObject)value["gadget"];

            List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>();


            GadgetParameters = new GadgetParameters();

            GadgetParameters.DatasourceName    = gadgetJSON["@DatasourceName"].ToString();
            GadgetParameters.InputVariableList = new Dictionary <string, string>();

            GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName);

            Mapper Mapper = new Controllers.Mapper();



            Rules = CommonClass.ReadRules(value);

            dashboardFilters = CommonClass.GetFilters(value);

            GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true);


            List <string> columnNames = new List <string>();
            Dictionary <string, string> inputVariableList = Mapper.MapJSONToRegressionInputVariableList(gadgetJSON);

            foreach (KeyValuePair <string, string> kvp in inputVariableList)
            {
                if (kvp.Value.ToLower().Equals("unsorted") || kvp.Value.ToLower().Equals("dependvar") || kvp.Value.ToLower().Equals("weightvar") || kvp.Value.ToLower().Equals("matchvar"))
                {
                    columnNames.Add(kvp.Key);
                }
                else if (kvp.Value.ToLower().Equals("discrete"))
                {
                    columnNames.Add(kvp.Key);
                }
            }
            List <DictionaryDTO> inputDtoList = new List <DictionaryDTO>();


            inputDtoList = Mapper.MapDictToList(inputVariableList);

            LinRegressionResults LinRegressionResults = LinearRegressionDomainService.GetRegressionResult(
                GadgetParameters,
                columnNames,
                inputDtoList,
                dashboardFilters,
                Rules,
                CommonClass.AdvancedDataFilterString);

            LinRegressionResults = Mapper.FormatLinRegressionResults(LinRegressionResults);



            var obj = new HttpResponseMessage()
            {
                Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(LinRegressionResults))//dt.GetJson())
            };

            obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            return(obj);
        }