private IEnumerable <KeyValuePair <HlaMsr1, KeyValuePair <double, bool> > > ExpandHla(HlaMsr1 hlaAbstractOrGround, LinkedList1 <HlaMsr1> linkedList1)
        {
            //Reference: http://en.wikipedia.org/wiki/Multinomial_logit#Model

            //Dictionary<string, Dictionary<HlaMsr1, double>> predictorNameToTargetHlaToWeight = Ethnicity.ClassNamePredictorNameOrInterceptToTargetToWeight[hlaAbstractOrGround.ClassName];
            EClass eclass = Ethnicity.HlaClassNameToEClass[hlaAbstractOrGround.ClassName];


            bool usedLowerResModel = false;

            foreach (LinkedList1 <int> hlaLengthList in eclass.HlaLengthListSorted())
            {
                bool      anyReturned = false;
                TableInfo tableInfo   = eclass.HlaLengthListToTableInfo[hlaLengthList];
                foreach (var hlaAndProb in ExpandHla(tableInfo, hlaAbstractOrGround, linkedList1))
                {
                    anyReturned = true;
                    yield return(new KeyValuePair <HlaMsr1, KeyValuePair <double, bool> >(hlaAndProb.Key, new KeyValuePair <double, bool>(hlaAndProb.Value, usedLowerResModel)));
                }
                if (anyReturned)
                {
                    yield break; // really yield break, not yield return or return;
                }
                usedLowerResModel = true;
            }
            throw new HlaNotInModelException(hlaAbstractOrGround.Name, string.Format("Can't find {0} or any prefix in any model", hlaAbstractOrGround.ToString(/*withParen*/ true)));
        }
示例#2
0
        static private Dictionary <string, Ethnicity> Init()
        {
            Dictionary <string, Ethnicity> ethnicityNameToEthnicity = new Dictionary <string, Ethnicity>();

            using (TextReader textReader = Linkdis.OpenResource("datafileList.txt"))
            {
                foreach (var row in SpecialFunctions.ReadDelimitedFile(textReader, new { Ethnicity = "", Class = "", HlaLengthList = "", FileName = "" }, new char[] { '\t' }, true))
                {
                    Ethnicity ethnicity          = ethnicityNameToEthnicity.GetValueOrDefault(row.Ethnicity.ToLowerInvariant());
                    EClass    eclass             = ethnicity.HlaClassNameToEClass.GetValueOrDefault(row.Class);
                    var       hlaLengthListQuery =
                        from hlaLengthAsString in row.HlaLengthList.Split(' ')
                        select int.Parse(hlaLengthAsString);

                    LinkedList1 <int> hlaLengthList = LinkedList1 <int> .GetInstanceFromList(hlaLengthListQuery.ToList());


                    TableInfo tableInfo = eclass.HlaLengthListToTableInfo.GetValueOrDefault(hlaLengthList);
                    tableInfo.HlaMsr1Factory = HlaMsr1Factory.GetFactory(hlaLengthList);
                    tableInfo.LoadTable(row.FileName, row.Class);
                }
            }
            return(ethnicityNameToEthnicity);
        }