예제 #1
0
 public override double[][] CreateDistribution(Leaf leaf, OptimizationParameterList discreteParameters, Converter <Leaf, SufficientStatistics> predClass)
 {
     //SpecialFunctions.CheckCondition(predClass == null, "The predictorToDistnClass closure is not null. Did you call the right method?");
     return(DefaultDistribution(leaf, discreteParameters));
 }
 public override double[][] CreateDistribution(Leaf leaf, OptimizationParameterList discreteParameters, Converter <Leaf, SufficientStatistics> predClass)
 {
     return(DefaultDistribution(leaf, discreteParameters));
 }
예제 #3
0
        public override void ReflectClassInDictionaries(DiscreteStatistics discreteStatistics, Leaf leaf,
                                                        ref Dictionary <string, BooleanStatistics> predictorMapToCreate, ref Dictionary <string, BooleanStatistics> targetMapToCreate)
        {
            string caseName = leaf.CaseName;

            if (!predictorMapToCreate.ContainsKey(caseName))
            {
                predictorMapToCreate.Add(caseName, false);
            }
            if (!targetMapToCreate.ContainsKey(caseName))
            {
                targetMapToCreate.Add(caseName, false);
            }

            int discreteClass = (int)discreteStatistics;

            switch ((DistributionClass)discreteClass)
            {
            case DistributionClass.FalseFalse:
                predictorMapToCreate[caseName] = false;
                targetMapToCreate[caseName]    = false;
                break;

            case DistributionClass.FalseTrue:
                predictorMapToCreate[caseName] = false;
                targetMapToCreate[caseName]    = true;
                break;

            case DistributionClass.TrueFalse:
                predictorMapToCreate[caseName] = true;
                targetMapToCreate[caseName]    = false;
                break;

            case DistributionClass.TrueTrue:
                predictorMapToCreate[caseName] = true;
                targetMapToCreate[caseName]    = true;
                break;

            default:
                SpecialFunctions.CheckCondition(false, "Shouldn't be here.");
                break;
            }
        }
예제 #4
0
        //public override string GetParameterHeaderString(string modifier)
        //{
        //    //string ParameterHeader = "Predictor Parameter" + (Use2PredictorParameters ? "1" : "") + modifier;
        //    //string header = SpecialFunctions.CreateTabString("x", "lambda", "LogLambda", ParameterHeader).Replace("\t", modifier + "\t");
        //    //if (Use2PredictorParameters)
        //    //    header += "\tPredictor Parameter2" + modifier;

        //    OptimizationParameterList parameters = GetParameters(true);
        //    StringBuilder headerString = new StringBuilder();
        //    foreach (OptimizationParameter param in parameters)
        //    {
        //        if (headerString.Length > 0)
        //        {
        //            headerString.Append("\t");
        //        }
        //        if (param.DoSearch)
        //        {
        //            headerString.Append(param.Name + modifier);
        //        }
        //    }
        //    return headerString.ToString();
        //}

        //public override string GetParameterValueString(OptimizationParameterList parameters)
        //{
        //    //double lambda = parameters[(int)ParameterIndex.Lambda].Value;
        //    //double x = parameters[(int)ParameterIndex.Equilibrium].Value;
        //    //double parameter1 = parameters[(int)ParameterIndex.Predictor1].Value;
        //    //double parameter2 = parameters[(int)ParameterIndex.Predictor2].Value;

        //    //String parameterString = parameter1.ToString() + (Use2PredictorParameters ? "\t" + parameter2.ToString() : "");
        //    //return SpecialFunctions.CreateTabString(x, lambda, Math.Log(lambda), parameterString);

        //    OptimizationParameterList exampleParams = GetParameters(true);
        //    StringBuilder valueString = new StringBuilder();
        //    foreach (OptimizationParameter param in exampleParams)
        //    {
        //        if (valueString.Length > 0)
        //        {
        //            valueString.Append("\t");
        //        }
        //        if (param.DoSearch)
        //        {
        //            valueString.Append(parameters[param.Name]);
        //        }
        //    }
        //    return valueString.ToString();
        //}

        public override void ReflectClassInDictionaries(DiscreteStatistics discreteStatistics, Leaf leaf, ref Dictionary <string, BooleanStatistics> predictorMapToCreate, ref Dictionary <string, BooleanStatistics> targetMapToCreate)
        {
            BooleanStatistics leafHasTarget = (int)discreteStatistics == (int)DistributionClass.True;

            if (!targetMapToCreate.ContainsKey(leaf.CaseName))
            {
                targetMapToCreate.Add(leaf.CaseName, leafHasTarget);
            }
            else
            {
                targetMapToCreate[leaf.CaseName] = leafHasTarget;
            }
        }