Beispiel #1
0
        public LogRegressionResults GetRegressionResult(GadgetParameters gadgetOptions, List <string> columnNames, List <DictionaryDTO> inputDtoList, IEnumerable <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString = "", string customFilter = "")
        {
            if (gadgetOptions.UseAdvancedDataFilter)
            {
                dh = new DashboardHelper(gadgetOptions, filterString, rules);
                gadgetOptions.UseAdvancedDataFilter  = true;
                gadgetOptions.AdvancedDataFilterText = filterString;
            }
            else
            {
                dh = new DashboardHelper(gadgetOptions, ewavDataFilters, rules);
            }
            DataTable dt;
            Dictionary <string, string> inputVariableList = RegressionManager.ConvertDtoToDic(inputDtoList);

            //LogRegressionResults results = new LogRegressionResults();
            StatisticsRepository.LogisticRegression logisticRegression = new StatisticsRepository.LogisticRegression();
            try
            {
                dt = dh.GenerateTable(columnNames, gadgetOptions, customFilter);
            }
            catch (System.Exception e)
            {
                throw new Exception("Error retrieving data from Dashboard Helper");
                //results.ErrorMessage = e.Message;
                //return results;
            }



            StatisticsRepository.LogisticRegression.LogisticRegressionResults regressionResults = logisticRegression.LogisticRegression(inputVariableList, dt);

            LogRegressionResults results = RegressionManager.ConvertToLogRegResults(regressionResults);

            //results.CasesIncluded = results.RegressionResults1.CasesIncluded;
            //results.Convergence = results.RegressionResults1.Convergence;
            //results.FinalLikelihood = results.RegressionResults1.FinalLikelihood;
            //results.Iterations = results.RegressionResults1.Iterations;
            //results.LRDF = results.RegressionResults1.LRDF;
            //results.LRP = results.RegressionResults1.LRP;
            //results.LRStatistic = results.RegressionResults1.LRStatistic;
            //results.ScoreDF = results.RegressionResults1.ScoreDF;
            //results.ScoreP = results.RegressionResults1.ScoreP;
            //results.ScoreStatistic = results.RegressionResults1.ScoreStatistic;
            //if (results.RegressionResults1.ErrorMessage != null)
            //{
            //    results.ErrorMessage = results.RegressionResults1.ErrorMessage.Replace("<tlt>", string.Empty).Replace("</tlt>", string.Empty);
            //}

            //results.Variables = results.RegressionResults1.Variables;


            return(results);
        }
Beispiel #2
0
        /// <summary>
        /// Calls dashboard helper to retrieve the table and coverts in Local representation of table
        /// </summary>
        /// <param name="DataSourceName"></param>
        /// <param name="TableName"></param>
        /// <param name="columnNames"></param>
        /// <returns></returns>
        public List <ListOfStringClass> GenerateTable(string DataSourceName, string TableName, List <string> columnNames)
        {
            List <ListOfStringClass> lls = new List <ListOfStringClass>();

            dh = new DashboardHelper();
            DataTable         dt  = dh.GenerateTable(columnNames);
            RegressionManager lrm = new RegressionManager();

            lls = lrm.ConvertDataTableToList(dt);
            return(new List <ListOfStringClass>());
        }
Beispiel #3
0
        public LinRegressionResults GetRegressionResult(GadgetParameters gadgetOptions, List <string> columnNames, List <DictionaryDTO> inputDtoList, IEnumerable <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString = "")
        {
            if (gadgetOptions.UseAdvancedDataFilter)
            {
                dh = new DashboardHelper(gadgetOptions, filterString, rules);
                gadgetOptions.UseAdvancedDataFilter  = true;
                gadgetOptions.AdvancedDataFilterText = filterString;
            }
            else
            {
                dh = new DashboardHelper(gadgetOptions, ewavDataFilters, rules);
            }
            DataTable            dt;
            LinRegressionResults results = new LinRegressionResults();

            try
            {
                dt = dh.GenerateTable(columnNames, gadgetOptions);
            }
            catch (Exception e)
            {
                results.ErrorMessage = e.Message;
                return(results);
            }
            Dictionary <string, string> inputVariableList = RegressionManager.ConvertDtoToDic(inputDtoList);


            StatisticsRepository.LinearRegression linearRegression = new StatisticsRepository.LinearRegression();

            StatisticsRepository.LinearRegression.LinearRegressionResults regressionResults = linearRegression.LinearRegression(inputVariableList, dt);

            results.RegressionResults = RegressionManager.ConvertToLinRegResults(regressionResults);

            results.CorrelationCoefficient = results.RegressionResults.CorrelationCoefficient;
            results.RegressionDf           = results.RegressionResults.RegressionDf;
            results.RegressionF            = results.RegressionResults.RegressionF;
            results.RegressionMeanSquare   = results.RegressionResults.RegressionMeanSquare;
            results.RegressionSumOfSquares = results.RegressionResults.RegressionSumOfSquares;
            results.ResidualsDf            = results.RegressionResults.ResidualsDf;
            results.ResidualsMeanSquare    = results.RegressionResults.ResidualsMeanSquare;
            results.ResidualsSumOfSquares  = results.RegressionResults.ResidualsSumOfSquares;
            results.TotalDf           = results.RegressionResults.TotalDf;
            results.TotalSumOfSquares = results.RegressionResults.TotalSumOfSquares;
            results.Variables         = results.RegressionResults.Variables;
            if (results.RegressionResults.ErrorMessage != null)
            {
                results.ErrorMessage = results.RegressionResults.ErrorMessage.Replace("<tlt>", string.Empty).Replace("</tlt>", string.Empty);
            }

            return(results);
        }
Beispiel #4
0
        public ScatterDataDTO GenerateTable(GadgetParameters gadgetOptions,
                                            IEnumerable <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString = "")
        {
            List <ListOfStringClass> lls = new List <ListOfStringClass>();

            if (gadgetOptions.UseAdvancedDataFilter)
            {
                dh = new DashboardHelper(gadgetOptions, filterString, rules);
                gadgetOptions.UseAdvancedDataFilter  = true;
                gadgetOptions.AdvancedDataFilterText = filterString;
            }
            else
            {
                dh = new DashboardHelper(gadgetOptions, ewavDataFilters, rules);
            }

            MyString ms       = new MyString();
            string   xAxisVar = gadgetOptions.MainVariableName;
            string   yAxisVar = gadgetOptions.CrosstabVariableName;

            List <string> columns = new List <string>();

            columns.Add(xAxisVar);
            columns.Add(yAxisVar);


            DataTable dt = dh.GenerateTable(columns, gadgetOptions);



            List <NumericDataValue> dataValues = new List <NumericDataValue>();
            NumericDataValue        minValue   = null;
            NumericDataValue        maxValue   = null;

            //regressTable.FieldsList.Fields

            //foreach (DataRow row in regressTable.Rows)
            foreach (DataRow row in dt.Rows)
            {
                //if (regressTable.GetValueAtRow(yAxisVar, row).Equals(DBNull.Value) || regressTable.GetValueAtRow(xAxisVar, row).Equals(DBNull.Value))
                if (row[yAxisVar].Equals(DBNull.Value) || row[xAxisVar].Equals(DBNull.Value))
                {
                    continue;
                }
                NumericDataValue currentValue = new NumericDataValue()
                {
                    DependentValue = Convert.ToDecimal(row[yAxisVar]), IndependentValue = Convert.ToDecimal(row[xAxisVar])
                };
                //NumericDataValue currentValue = new NumericDataValue() { DependentValue = Convert.ToDecimal(regressTable.GetValueAtRow(yAxisVar, row)), IndependentValue = Convert.ToDecimal(regressTable.GetValueAtRow(xAxisVar, row)) };
                dataValues.Add(currentValue);
                if (minValue == null)
                {
                    minValue = currentValue;
                }
                else
                {
                    if (currentValue.IndependentValue < minValue.IndependentValue)
                    {
                        minValue = currentValue;
                    }
                }
                if (maxValue == null)
                {
                    maxValue = currentValue;
                }
                else
                {
                    if (currentValue.IndependentValue > maxValue.IndependentValue)
                    {
                        maxValue = currentValue;
                    }
                }
            }

            StatisticsRepository.LinearRegression linearRegression  = new StatisticsRepository.LinearRegression();
            Dictionary <string, string>           inputVariableList = new Dictionary <string, string>();

            inputVariableList.Add(yAxisVar, "dependvar");
            inputVariableList.Add("intercept", "true");
            inputVariableList.Add("includemissing", "false");
            inputVariableList.Add("p", "0.95");
            inputVariableList.Add(xAxisVar, "unsorted");

            StatisticsRepository.LinearRegression.LinearRegressionResults regresResults = linearRegression.LinearRegression(inputVariableList, dt);
            LinRegressionResults results = new LinRegressionResults();

            results = RegressionManager.ConvertToLinRegResults(regresResults);

            //results.CorrelationCoefficient = results.RegressionResults.CorrelationCoefficient;
            //results.RegressionDf = results.RegressionResults.RegressionDf;
            //results.RegressionF = results.RegressionResults.RegressionF;
            //results.RegressionMeanSquare = results.RegressionResults.RegressionMeanSquare;
            //results.RegressionSumOfSquares = results.RegressionResults.RegressionSumOfSquares;
            //results.ResidualsDf = results.RegressionResults.ResidualsDf;
            //results.ResidualsMeanSquare = results.RegressionResults.ResidualsMeanSquare;
            //results.ResidualsSumOfSquares = results.RegressionResults.ResidualsSumOfSquares;
            //results.TotalDf = results.RegressionResults.TotalDf;
            //results.TotalSumOfSquares = results.RegressionResults.TotalSumOfSquares;
            //results.Variables = results.RegressionResults.Variables;
            if (results.ErrorMessage != null)
            {
                results.ErrorMessage = results.ErrorMessage.Replace("<tlt>", string.Empty).Replace("</tlt>", string.Empty);
            }


            ScatterDataDTO scatterDTO = new ScatterDataDTO();

            scatterDTO.DataValues    = dataValues;
            scatterDTO.RegresResults = results;
            scatterDTO.MinValue      = minValue;
            scatterDTO.MaxValue      = maxValue;

            //RegressionManager lrm = new RegressionManager();
            //lls = lrm.ConvertDataTableToList(dt);
            //return new List<ListOfStringClass>();

            return(scatterDTO);
        }