Beispiel #1
0
 /// <summary>
 /// Initialize the outputTable
 /// </summary>
 /// <param name="rowCount">rowCount of output table</param>
 /// <param name="predictedfield">predictedfield name</param>
 /// <param name="predictedCategories">probableFields</param>
 private void InitializeTable(int rowCount, string[] predictedCategories)
 {
     //Create instance to hold evaluated results
     outputTable = new Syncfusion.PMML.Table(rowCount, predictedCategories.Length + 1);
     //Add predicted column names
     outputTable.ColumnNames[0] = "Predicted";
 }
Beispiel #2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var    value     = 0;
            string pmmlPath  = "../../Model/kmeans_data.pmml";
            string inputPath = "../../Model/kmeans_data.txt";

            string[] lines = System.IO.File.ReadAllLines(inputPath);
            outputTable = PredictResult(lines, pmmlPath);
            DataTable inputDataTable = new DataTable();

            string[] words = lines[0].Split(' ');
            value = words.Length;
            for (int i = 0; i < value; i++)
            {
                inputDataTable.Columns.Add("field_" + i);
            }
            foreach (var item in lines)
            {
                words = item.Split(' ');
                inputDataTable.Rows.Add(words);
            }
            var MergedDataTable = MergeTable(inputDataTable, outputTable);

            SfDataGrid.ItemsSource = MergedDataTable;
            for (int i = 0; i < MergedDataTable.Columns.Count; i++)
            {
                if (i >= value)
                {
                    SfDataGrid.Columns[i].CellStyle = System.Windows.Application.Current.Resources["predictedColumnColor"] as Style;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method to load Samples
        /// </summary>
        /// <param name="sample">Sample values</param>
        public void LoadGeneralRegressionAuditSample(Sample sample, DataManager dataManager)
        {
            AuditLogitClassification.Program audit = new AuditLogitClassification.Program();

            var    path        = sample.GetParentDirectoryPath(Server.MapPath("~"));
            string samplePath  = string.Format("{0}{1}\\{2}", path, sample.SamplePath, "Model\\");
            string outputPath  = samplePath + "PredictedOutput.html";
            string pmmlPath    = string.Format("{0}{1}.pmml", samplePath, "Audit");
            string rScriptPath = string.Format("{0}{1}.R", samplePath, "Audit");

            string inputPath              = samplePath + "Audit.csv";
            Table  inputTable             = new Syncfusion.PMML.Table(inputPath, true, ',');
            Table  selectedPageInputTable = sample.PagingMethod(inputTable, dataManager, dataManager != null ? dataManager.Skip : 0);
            Table  outputTable            = audit.PredictResult(selectedPageInputTable, pmmlPath);

            ViewBag.output = sample.serializeTable(inputTable, outputTable, dataManager != null ? dataManager.Skip : 0);

            Dictionary <string, List <string> > columnCollection = sample.GetColumnNames(inputTable, outputTable);

            ViewBag.InputColumns         = columnCollection["inputColumns"];
            ViewBag.OutputColumns        = columnCollection["outputColumns"];
            ViewBag.InputNumericColumns  = columnCollection["inputNumericColumns"];
            ViewBag.OutputNumericColumns = columnCollection["outputNumericColumns"];

            if (System.IO.File.Exists(rScriptPath))
            {
                ViewBag.RScript = System.IO.File.ReadAllText(rScriptPath);
            }

            ViewBag.PMML = System.IO.File.ReadAllText(pmmlPath);
        }
Beispiel #4
0
        /// <summary>
        /// Serialize the values in a list
        /// </summary>
        /// <param name="inputTable">input table values</param>
        /// <param name="outputTable">output table values</param>
        public void serializeTable(Syncfusion.PMML.Table inputTable, Syncfusion.PMML.Table outputTable)
        {
            List <AuditLogitClassification> datasource = new List <AuditLogitClassification>();

            for (int i = 0; i < inputTable.RowCount; i++)
            {
                AuditLogitClassification auditLogit = new AuditLogitClassification();

                auditLogit.ID                       = inputTable[i, 0];
                auditLogit.Age                      = inputTable[i, 1];
                auditLogit.Employment               = inputTable[i, 2];
                auditLogit.Education                = inputTable[i, 3];
                auditLogit.Marital                  = inputTable[i, 4];
                auditLogit.Occupation               = inputTable[i, 5];
                auditLogit.Income                   = inputTable[i, 6];
                auditLogit.Sex                      = inputTable[i, 7];
                auditLogit.Deductions               = inputTable[i, 8];
                auditLogit.Hours                    = inputTable[i, 9];
                auditLogit.Accounts                 = inputTable[i, 10];
                auditLogit.Adjustment               = inputTable[i, 11];
                auditLogit.Adjusted                 = inputTable[i, 12];
                auditLogit.Predicted_Adjusted       = outputTable[i, 0];
                auditLogit.AuditLowriskProbability  = outputTable[i, 1];
                auditLogit.AuditHighriskProbability = outputTable[i, 2];

                //Adds audit object to grid's datasource
                datasource.Add(auditLogit);
            }

            ViewBag.datasource = datasource;
        }
Beispiel #5
0
 /// <summary>
 /// Initialize the outputTable
 /// </summary>
 /// <param name="rowCount">rowCount of output table</param>
 /// <param name="predictedfield">predictedfield name</param>
 /// <param name="predictedCategories">probableFields</param>
 private void InitializeTable(int rowCount, string predictedfield, string[] predictedCategories)
 {
     //Create instance to hold evaluated results
     outputTable = new Table(rowCount, predictedCategories.Length + 1);
     //Add predicted column names
     outputTable.ColumnNames[0] = "Predicted_" + predictedfield;
     outputTable.ColumnNames[1] = "AuditLowriskProbability";
     outputTable.ColumnNames[2] = "AuditHighriskProbability";
 }
Beispiel #6
0
        private DataTable MergeTable(DataTable inputDataTable, Syncfusion.PMML.Table outputTable)
        {
            var    lenth     = 0;
            string pmmlPath  = "../../Model/lpsa.pmml";
            string inputPath = "../../Model/lpsa.data";

            string[] lines = System.IO.File.ReadAllLines(inputPath);
            outputTable = PredictResult(lines, pmmlPath);
            string[] inputValues    = lines[0].Split(' ');
            string[] fieldAndTarget = inputValues[0].Split(',');
            lenth = inputValues.Length;
            for (int i = 0; i < lenth; i++)
            {
                if (i == 0)
                {
                    inputDataTable.Columns.Add("target");
                }
                inputDataTable.Columns.Add("field_" + i);
            }
            foreach (var item in lines)
            {
                fieldAndTarget = item.Split(',');
                var inputList = new List <string>();
                inputList.Add(fieldAndTarget[0]);
                inputValues = fieldAndTarget[1].Split(' ');
                foreach (var word in inputValues)
                {
                    inputList.Add(word);
                }

                inputValues = inputList.ToArray <string>();
                lenth       = inputList.Count;
                inputDataTable.Rows.Add(inputValues);
            }
            var columnEnumarator = outputTable.ColumnNames.GetEnumerator();

            while (columnEnumarator.MoveNext())
            {
                var column = new DataColumn()
                {
                    ColumnName = columnEnumarator.Current.ToString()
                };
                inputDataTable.Columns.Add(column);
            }

            for (int i = 0; i < inputDataTable.Rows.Count; i++)
            {
                for (int j = 0; j < outputTable.ColumnNames.Length; j++)
                {
                    inputDataTable.Rows[i].SetField(outputTable.ColumnNames[j], outputTable[i, j]);
                }
            }

            return(inputDataTable);
        }
Beispiel #7
0
        /// <summary>
        /// Method to load Samples
        /// </summary>
        /// <param name="sample">Sample values</param>
        public void LoadSample()
        {
            samplePath = _hostingEnvironment.WebRootPath + @"/PredictiveAnalytics/";

            inputPath = samplePath + "Audit.csv";
            pmmlPath  = string.Format("{0}{1}.pmml", samplePath, "Audit");
            Stream inputStream = new FileStream(inputPath, FileMode.Open, FileAccess.Read);

            inputTable  = new Syncfusion.PMML.Table(inputStream, true, ',');
            outputTable = PredictResult(inputTable, pmmlPath);

            serializeTable(inputTable, outputTable);
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var    lenth     = 0;
            string pmmlPath  = "../../Model/lpsa.pmml";
            string inputPath = "../../Model/lpsa.data";

            string[] lines = System.IO.File.ReadAllLines(inputPath);
            outputTable = PredictResult(lines, pmmlPath);
            DataTable inputDataTable = new DataTable();

            string[] inputValues    = lines[0].Split(' ');
            string[] fieldAndTarget = inputValues[0].Split(',');
            lenth = inputValues.Length;
            for (int i = 0; i < lenth; i++)
            {
                if (i == 0)
                {
                    inputDataTable.Columns.Add("target");
                }
                inputDataTable.Columns.Add("field_" + i);
            }
            foreach (var item in lines)
            {
                fieldAndTarget = item.Split(',');
                var inputList = new List <string>();
                inputList.Add(fieldAndTarget[0]);
                inputValues = fieldAndTarget[1].Split(' ');
                foreach (var word in inputValues)
                {
                    inputList.Add(word);
                }

                inputValues = inputList.ToArray <string>();
                lenth       = inputList.Count;
                inputDataTable.Rows.Add(inputValues);
            }
            var MergedDataTable = MergeTable(inputDataTable, outputTable);

            SfDataGrid.ItemsSource = MergedDataTable;
            for (int i = 0; i < MergedDataTable.Columns.Count; i++)
            {
                if (i >= lenth)
                {
                    SfDataGrid.Columns[i].CellStyle = System.Windows.Application.Current.Resources["predictedColumnColor"] as Style;
                }
            }
        }
Beispiel #9
0
        private DataTable MergeTable(DataTable inputDataTable, Syncfusion.PMML.Table outputTable)
        {
            var    value     = 0;
            string pmmlPath  = "../../Model/kmeans_data.pmml";
            string inputPath = "../../Model/kmeans_data.txt";

            string[] lines = System.IO.File.ReadAllLines(inputPath);
            outputTable = PredictResult(lines, pmmlPath);
            string[] words = lines[0].Split(' ');
            value = words.Length;
            for (int i = 0; i < value; i++)
            {
                inputDataTable.Columns.Add("field_" + i);
            }
            foreach (var item in lines)
            {
                words = item.Split(' ');
                inputDataTable.Rows.Add(words);
            }
            var columnEnumarator = outputTable.ColumnNames.GetEnumerator();

            while (columnEnumarator.MoveNext())
            {
                var column = new DataColumn()
                {
                    ColumnName = columnEnumarator.Current.ToString()
                };
                inputDataTable.Columns.Add(column);
            }

            for (int i = 0; i < inputDataTable.Rows.Count; i++)
            {
                for (int j = 0; j < outputTable.ColumnNames.Length; j++)
                {
                    inputDataTable.Rows[i].SetField(outputTable.ColumnNames[j], outputTable[i, j]);
                }
            }

            return(inputDataTable);
        }
Beispiel #10
0
        private DataTable MergeTable(DataTable inputDataTable, Syncfusion.PMML.Table outputTable)
        {
            var columnEnumarator = outputTable.ColumnNames.GetEnumerator();

            while (columnEnumarator.MoveNext())
            {
                var column = new DataColumn()
                {
                    ColumnName = columnEnumarator.Current.ToString()
                };
                inputDataTable.Columns.Add(column);
            }

            for (int i = 0; i < inputDataTable.Rows.Count; i++)
            {
                for (int j = 0; j < outputTable.ColumnNames.Length; j++)
                {
                    inputDataTable.Rows[i].SetField(outputTable.ColumnNames[j], outputTable[i, j]);
                }
            }

            return(inputDataTable);
        }