Beispiel #1
0
        GetPunchedCardsPerKeyPerLabel(
            IReadOnlyList <Tuple <IBitVector, IBitVector> > trainingData,
            IPuncher <string, IBitVector, IBitVector> puncher)
        {
            var count = trainingData[0].Item1.Count;

            return(puncher
                   .GetKeys(count)
                   .AsParallel()
                   .Select(key => Tuple.Create(
                               key,
                               GetPunchedCardsPerLabel(trainingData.Select(trainingDataItem =>
                                                                           Tuple.Create(puncher.Punch(key, trainingDataItem.Item1), trainingDataItem.Item2)))))
                   .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2));
        }
        GetPunchedCardsPerKeyPerLabel(
            IList <Tuple <IBitVector, IBitVector> > trainingData,
            IPuncher <string, IBitVector, IBitVector> puncher)
        {
            var count = trainingData[0].Item1.Count;

            var punchedCardsPerKeyPerLabel = new Dictionary <
                string,
                IDictionary <IBitVector, IReadOnlyCollection <Tuple <IBitVector, int> > > >();

            puncher
            .GetKeys(count)
            .AsParallel()
            .ForAll(key =>
            {
                punchedCardsPerKeyPerLabel.Add(key,
                                               GetPunchedCardsPerLabel(trainingData.Select(trainingDataItem =>
                                                                                           new Tuple <IPunchedCard <string, IBitVector>, IBitVector>(
                                                                                               puncher.Punch(key, trainingDataItem.Item1), trainingDataItem.Item2))));
            });
            return(punchedCardsPerKeyPerLabel);
        }