コード例 #1
0
        /*
         * Init checkbox fields to exclude the key attribute
         */
        void InitAttributeAndMeasures(string sQuery, GridView objGrid)
        {
            MiningManager objMiningManager = new MiningManager();

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

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

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sAtributes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            objGrid.DataSource = sAtributes;
            objGrid.DataBind();
        }
コード例 #2
0
        /*
         * Init all cubes
         */
        private void InitCubes()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT CUBE_NAME FROM $system.mdschema_cubes WHERE left(CUBE_NAME, 1) <> '$' AND len(BASE_CUBE_NAME) = 0";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

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

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListCubes.DataSource = sCubes;
            DropDownListCubes.DataBind();
        }
コード例 #3
0
        /*
         * Init all dimension names into a listbox
         */
        private void InitDimensionNames()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT DIMENSION_NAME FROM $system.mdschema_dimensions WHERE CUBE_NAME = '" +
                            DropDownListCubes.SelectedItem.Text + "'";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

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

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListDimensions.DataSource = sCubes;
            DropDownListDimensions.DataBind();
        }
コード例 #4
0
        /*
         * Init all attributes
         */
        private void InitAttributes()
        {
            // clear current query
            DropDownListKey.DataSource = null;
            DropDownListKey.DataBind();

            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                            DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                            DropDownListDimensions.SelectedItem.Text + "]'";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

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

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListKey.DataSource = sCubes;
            DropDownListKey.DataBind();

            // init input columns
            sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                     DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                     DropDownListDimensions.SelectedItem.Text + "]' AND HIERARCHY_NAME <> '" + DropDownListKey.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewAttributes);

            // init measures
            sQuery = "SELECT MEASURE_NAME FROM $system.mdschema_measures WHERE CUBE_NAME = '" +
                     DropDownListCubes.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewMeasures);
        }
コード例 #5
0
        /*
         * Build mining structure
         */
        protected void ButtonStructure_Click(object sender, EventArgs e)
        {
            // Create mining structure based on column and table selection
            List<string> lsInputItems = new List<string>();
            List<string> lsPredictItems = new List<string>();
            List<string> lsInputMeasures = new List<string>();
            List<string> lsPredictMeasures = new List<string>();
            List<bool> lbPredictItems = new List<bool>();

            //Dictionary<string /* column name */, bool /* only predict = true; predict = false*/> objPredictItems = new Dictionary<string, bool>();

            // input items
            foreach (GridViewRow row in GridViewAttributes.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxAtrInput");

                if (cb != null && cb.Checked)
                    lsInputItems.Add(row.Cells[2].Text);
            }

            foreach (GridViewRow row in GridViewMeasures.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxMeasureInput");

                if (cb != null && cb.Checked)
                    lsInputMeasures.Add(row.Cells[2].Text);
            }

            // predict items
            foreach (GridViewRow row in GridViewAttributes.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxAtrPredict");

                if (cb != null && cb.Checked)
                {
                    // check input column
                    bool bIsPredictOnly = true;

                    // iterate input list and if the item is found in the list then set bool to false
                    for (int i = 0; i < lsInputItems.Count; i++)
                    {
                        if (lsInputItems[i] == row.Cells[2].Text)
                        {
                            bIsPredictOnly = false;
                            break;
                        }
                    }

                    lsPredictItems.Add(row.Cells[2].Text);
                    lbPredictItems.Add(bIsPredictOnly);
                }
            }

            foreach (GridViewRow row in GridViewMeasures.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxMeasurePredict");

                if (cb != null && cb.Checked)
                    lsPredictMeasures.Add(row.Cells[2].Text);
            }

            // check clustering parameter
            try
            {
                int x = Convert.ToInt32(TextBoxCount.Text);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                LabelStatus.Text = "Please make sure that the parameter is a number!";
            }

            string sStructName = TextBoxName.Text;
            if (sStructName == "")
                sStructName = "MyMiningStructure";

            string objAlgorithm = null;

            // parameters
            int parOne = 0;
            int parTwo = 0;

            // create mining structure
            if (DropDownListAlgorithm.SelectedIndex == 0)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftClustering;
                parOne = DropDownListMethod.SelectedIndex + 1;
                parTwo = Convert.ToInt32(TextBoxCount.Text);
            }
            else if (DropDownListAlgorithm.SelectedIndex == 1)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftDecisionTrees;
                parOne = DropDownListScore.SelectedIndex + 1;
                parTwo = DropDownListSplit.SelectedIndex + 1;
            }
            else if (DropDownListAlgorithm.SelectedIndex == 2)
                objAlgorithm = MiningModelAlgorithms.MicrosoftNaiveBayes;
            else if (DropDownListAlgorithm.SelectedIndex == 3)
                objAlgorithm = MiningModelAlgorithms.MicrosoftTimeSeries;

            // warn at missing input column
            if (lsInputItems.Count == 0)
            {
                LabelStatus.Text = "Please select at least one input column!";
                return;
            }

            // warn at prediction column missing for naive bayes and decision trees
            if (objAlgorithm == MiningModelAlgorithms.MicrosoftNaiveBayes || objAlgorithm == MiningModelAlgorithms.MicrosoftDecisionTrees)
            {
                if (lsInputItems.Count == 0 || lsPredictItems.Count == 0)
                {
                    LabelStatus.Text = "Please select at least one input column and at least one prediction column!";
                    return;
                }
            }

            MiningManager objMiningManager = new MiningManager();

            // Create mining query from the existing results
            string sResult = objMiningManager.CreateCubeMiningStructure(sStructName, objAlgorithm, DropDownListCubes.SelectedIndex, DropDownListDimensions.SelectedItem.Text,
                DropDownListKey.SelectedItem.Text, lsInputItems, lsPredictItems, lsInputMeasures, lsPredictMeasures, lbPredictItems, parOne, parTwo);

            if (sResult == "Success")
            {
                LabelStatus.Text = "Rezultatul procesului: Success!";
                LoadExistingStructures();
            }
            else
                LabelStatus.Text = "Rezultatul procesului: Eroare - " + sResult;
        }
コード例 #6
0
        /*
         * Init all dimension names into a listbox
         */
        private void InitDimensionNames()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT DIMENSION_NAME FROM $system.mdschema_dimensions WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "'";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sCubes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListDimensions.DataSource = sCubes;
            DropDownListDimensions.DataBind();
        }
コード例 #7
0
        /*
         * Init all cubes
         */
        private void InitCubes()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT CUBE_NAME FROM $system.mdschema_cubes WHERE left(CUBE_NAME, 1) <> '$' AND len(BASE_CUBE_NAME) = 0";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sCubes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListCubes.DataSource = sCubes;
            DropDownListCubes.DataBind();
        }
コード例 #8
0
        /*
         * Init all attributes
         */
        private void InitAttributes()
        {
            // clear current query
            DropDownListKey.DataSource = null;
            DropDownListKey.DataBind();

            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                DropDownListDimensions.SelectedItem.Text + "]'";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

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

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListKey.DataSource = sCubes;
            DropDownListKey.DataBind();

            // init input columns
            sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                DropDownListDimensions.SelectedItem.Text + "]' AND HIERARCHY_NAME <> '" + DropDownListKey.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewAttributes);

            // init measures
            sQuery = "SELECT MEASURE_NAME FROM $system.mdschema_measures WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewMeasures);
        }
コード例 #9
0
        /*
         * Init checkbox fields to exclude the key attribute
         */
        void InitAttributeAndMeasures(string sQuery, GridView objGrid)
        {
            MiningManager objMiningManager = new MiningManager();

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sAtributes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sAtributes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            objGrid.DataSource = sAtributes;
            objGrid.DataBind();
        }
コード例 #10
0
        /*
         * Build mining structure
         */
        protected void ButtonStructure_Click(object sender, EventArgs e)
        {
            // Create mining structure based on column and table selection
            List <string> lsInputItems      = new List <string>();
            List <string> lsPredictItems    = new List <string>();
            List <string> lsInputMeasures   = new List <string>();
            List <string> lsPredictMeasures = new List <string>();
            List <bool>   lbPredictItems    = new List <bool>();

            //Dictionary<string /* column name */, bool /* only predict = true; predict = false*/> objPredictItems = new Dictionary<string, bool>();

            // input items
            foreach (GridViewRow row in GridViewAttributes.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxAtrInput");

                if (cb != null && cb.Checked)
                {
                    lsInputItems.Add(row.Cells[2].Text);
                }
            }

            foreach (GridViewRow row in GridViewMeasures.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxMeasureInput");

                if (cb != null && cb.Checked)
                {
                    lsInputMeasures.Add(row.Cells[2].Text);
                }
            }

            // predict items
            foreach (GridViewRow row in GridViewAttributes.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxAtrPredict");

                if (cb != null && cb.Checked)
                {
                    // check input column
                    bool bIsPredictOnly = true;

                    // iterate input list and if the item is found in the list then set bool to false
                    for (int i = 0; i < lsInputItems.Count; i++)
                    {
                        if (lsInputItems[i] == row.Cells[2].Text)
                        {
                            bIsPredictOnly = false;
                            break;
                        }
                    }

                    lsPredictItems.Add(row.Cells[2].Text);
                    lbPredictItems.Add(bIsPredictOnly);
                }
            }


            foreach (GridViewRow row in GridViewMeasures.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBoxMeasurePredict");

                if (cb != null && cb.Checked)
                {
                    lsPredictMeasures.Add(row.Cells[2].Text);
                }
            }

            // check clustering parameter
            try
            {
                int x = Convert.ToInt32(TextBoxCount.Text);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                LabelStatus.Text = "Please make sure that the parameter is a number!";
            }

            string sStructName = TextBoxName.Text;

            if (sStructName == "")
            {
                sStructName = "MyMiningStructure";
            }

            string objAlgorithm = null;

            // parameters
            int parOne = 0;
            int parTwo = 0;

            // create mining structure
            if (DropDownListAlgorithm.SelectedIndex == 0)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftClustering;
                parOne       = DropDownListMethod.SelectedIndex + 1;
                parTwo       = Convert.ToInt32(TextBoxCount.Text);
            }
            else if (DropDownListAlgorithm.SelectedIndex == 1)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftDecisionTrees;
                parOne       = DropDownListScore.SelectedIndex + 1;
                parTwo       = DropDownListSplit.SelectedIndex + 1;
            }
            else if (DropDownListAlgorithm.SelectedIndex == 2)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftNaiveBayes;
            }
            else if (DropDownListAlgorithm.SelectedIndex == 3)
            {
                objAlgorithm = MiningModelAlgorithms.MicrosoftTimeSeries;
            }


            // warn at missing input column
            if (lsInputItems.Count == 0)
            {
                LabelStatus.Text = "Please select at least one input column!";
                return;
            }

            // warn at prediction column missing for naive bayes and decision trees
            if (objAlgorithm == MiningModelAlgorithms.MicrosoftNaiveBayes || objAlgorithm == MiningModelAlgorithms.MicrosoftDecisionTrees)
            {
                if (lsInputItems.Count == 0 || lsPredictItems.Count == 0)
                {
                    LabelStatus.Text = "Please select at least one input column and at least one prediction column!";
                    return;
                }
            }

            MiningManager objMiningManager = new MiningManager();

            // Create mining query from the existing results
            string sResult = objMiningManager.CreateCubeMiningStructure(sStructName, objAlgorithm, DropDownListCubes.SelectedIndex, DropDownListDimensions.SelectedItem.Text,
                                                                        DropDownListKey.SelectedItem.Text, lsInputItems, lsPredictItems, lsInputMeasures, lsPredictMeasures, lbPredictItems, parOne, parTwo);

            if (sResult == "Success")
            {
                LabelStatus.Text = "Rezultatul procesului: Success!";
                LoadExistingStructures();
            }
            else
            {
                LabelStatus.Text = "Rezultatul procesului: Eroare - " + sResult;
            }
        }