Example #1
0
        public static ModelEvaluatorDiscreteConditional GetInstance(string leafDistributionName, ModelScorer modelScorer, bool includePredictorInScore)
        {
            DistributionDiscreteSingleVariable nullDistn = DistributionDiscreteSingleVariable.GetInstance();
            DistributionDiscreteConditional    condDistn = DistributionDiscreteConditional.GetInstance(leafDistributionName);

            return(new ModelEvaluatorDiscreteConditional(nullDistn, condDistn, modelScorer, includePredictorInScore));
        }
Example #2
0
 public static DistributionDiscreteSingleVariable GetInstance()
 {
     if (Instance == null)
     {
         Instance = new DistributionDiscreteSingleVariable();
     }
     return(Instance);
 }
Example #3
0
 protected ModelEvaluatorDiscreteConditional(
     DistributionDiscreteSingleVariable nullDistn,
     DistributionDiscreteConditional conditionalDistn,
     ModelScorer scorer,
     bool includePredictorInScore)
     : base(SpecialFunctions.CreateSingletonList <IDistributionSingleVariable>(nullDistn), conditionalDistn, scorer)
 {
     _includePredictorInScore = includePredictorInScore;
 }
Example #4
0
        new public static ModelEvaluatorDiscreteJoint GetInstance(string leafDistributionName, ModelScorer modelScorer)
        {
            DistributionDiscreteSingleVariable nullDistn  = DistributionDiscreteSingleVariable.GetInstance();
            DistributionDiscreteJoint          jointDistn = DistributionDiscreteJoint.GetInstance(leafDistributionName);
            List <IDistributionSingleVariable> nullDistns = new List <IDistributionSingleVariable>();

            nullDistns.Add(nullDistn);
            nullDistns.Add(nullDistn);

            return(new ModelEvaluatorDiscreteJoint(nullDistns, jointDistn, modelScorer));
        }
Example #5
0
        protected Score ComputeSingleVariableScore(
            Converter <Leaf, SufficientStatistics> predictorMap,
            Converter <Leaf, SufficientStatistics> targetMap,
            DistributionDiscreteSingleVariable nullDistn,
            int[] fisherCounts,
            out bool variableIsInvariant)
        {
            MessageInitializerDiscrete nullMessageInitializer =
                MessageInitializerDiscrete.GetInstance(predictorMap, targetMap, nullDistn, fisherCounts, ModelScorer.PhyloTree.LeafCollection);

            double p = (double)TwoByTwo.GetRightSum(fisherCounts) / SpecialFunctions.Sum(fisherCounts);
            Score  nullScore;

            if (TryGetSingleVariableScoreFromCounts(nullMessageInitializer, p, out nullScore))
            {
                variableIsInvariant = true;
            }
            else
            {
                variableIsInvariant = false;
                nullScore           = ModelScorer.MaximizeLikelihood(nullMessageInitializer);
            }
            return(nullScore);
        }
Example #6
0
 protected ModelEvaluatorDiscreteFisher(IEnumerable <Leaf> fullLeafCollection)
     : base(SpecialFunctions.CreateSingletonList <IDistributionSingleVariable>(DistributionDiscreteSingleVariable.GetInstance()),
            null, null) // null model is a hack to avoid null exceptions at load time.
 {
     _fullLeafCollection = fullLeafCollection;
 }