Beispiel #1
0
        public double[] calculateOutput(bool isTraining, bool probValue = false)
        {
            if (Factory.ProgresReport.BestSolution == null)
            {
                return(null);
            }
            //
            var ch  = Factory.ProgresReport.BestSolution;//.expressionTree;
            var par = Factory.Parameters;

            if (par.RootFunctionNode == null)
            {
                setLearningType(par);
            }
            double[] yc = null;
            if (ch != null)
            {
                yc = Inputs.CalculateOutput(ch, par, isTraining);//gp

                //no testing data set
                if (yc == null)
                {
                    return(null);
                }

                //de normalize output
                double[] output = yc;
                for (int i = 0; i < yc.Length; i++)
                {
                    //calculate de normalization
                    if (ExpData.GetOutputColumnType() == ColumnType.Numeric)
                    {
                        double[] normRow = new double[1] {
                            yc[i]
                        };
                        output[i] = ExpData.GetDecodedOutputRow(normRow)[0];
                    }
                    else
                    {
                        if (par.RootFunctionNode.Id == 2048) //sigmoid
                        {
                            if (probValue)                   //when model is evaluate we need probability f event in order to optimize threshold value
                            {
                                output[i] = yc[i];
                            }
                            else
                            {
                                output[i] = yc[i] > par.RootFunctionNode.Parameter ? 1 : 0;
                            }
                        }
                        else if (par.RootFunctionNode.Id == 2050)//step
                        {
                            output[i] = Math.Truncate(yc[i]);
                        }
                        else
                        {
                            output[i] = Math.Truncate(yc[i]);
                        }
                    }
                }
                return(output);
            }
            return(null);//no solution yet
        }