/// <summary>
        /// The prediction method which can be called from SQL Server
        /// </summary>
        /// <param name="inputCase"></param>
        /// <param name="predictionResult"></param>
        protected override void Predict(MiningCase inputCase, PredictionResult predictionResult)
        {
            //the input values and predictec label
            double[] values;
            uint     label         = 0;
            int      attributeSize = 0;

            //convert and scale the input
            getValues(inputCase, out values, out label, out attributeSize);
            Instance instance = new Instance(1, (int)label, values, getLabels());

            //obtain the votes
            int[] votes = getVotes(instance);
            label = 0;
            for (uint i = 1; i < votes.Length; i++)
            {
                if (votes[i] > votes[label])
                {
                    label = i;
                }
            }

            //construct the output
            AttributeStatistics attStats = new AttributeStatistics();

            attStats.Attribute = getTargetAttribute();
            StateStatistics stateStat = new StateStatistics();
            StateValue      stateVal  = new StateValue();

            stateVal.SetIndex(label);

            stateStat.Value = AttributeSet.TokenizeAttributeValue(attStats.Attribute, AttributeSet.UntokenizeAttributeValue(attStats.Attribute, stateVal));
            attStats.StateStatistics.Add(stateStat);
            predictionResult.AddPrediction(attStats);
        }
        /// <summary>
        /// returns the names of the attributes
        /// </summary>
        /// <returns></returns>
        public String[] getAttributeNames()
        {
            LinkedList <string> values = new LinkedList <string>();

            //SortedDictionary<uint, double>.Enumerator enumerator = dict.GetEnumerator();
            for (uint i = 0; i < AttributeSet.GetAttributeCount(); i++)
            {
                if (!isNominal(i))
                {
                    values.AddLast(AttributeSet.GetAttributeDisplayName(i, false));
                }
                else
                {
                    if (!isTarget(i))
                    {
                        for (uint j = 0; j < AttributeSet.GetAttributeStateCount(i); j++)
                        {
                            StateValue value = new StateValue();
                            value.SetIndex(j);
                            object valuea = AttributeSet.UntokenizeAttributeValue(i, value);
                            string name;
                            if (valuea == null)
                            {
                                name = "NULL";
                            }
                            else
                            {
                                name = valuea.ToString();
                                if (name.Equals(""))
                                {
                                    name = "NULL";
                                }
                            }
                            values.AddLast(AttributeSet.GetAttributeDisplayName(i, false) + "." + name);
                        }
                    }
                }
            }
            string[] output = new string[values.Count];
            values.CopyTo(output, 0);
            return(output);
        }
        public System.Data.DataTable GetClasses()
        {
            //construct the table column names
            System.Data.DataTable table = new System.Data.DataTable();

            table.Columns.Add("Columns", typeof(string));

            if (Context.ExecuteForPrepare)
            {
                return(table);
            }


            for (uint i = 0; i < this.AttributeSet.GetAttributeStateCount(getTargetAttribute()); i++)
            {
                StateValue value = new StateValue();
                value.SetIndex(i);
                table.Rows.Add(this.AttributeSet.UntokenizeAttributeValue(getTargetAttribute(), value));
            }

            return(table);
        }