Example #1
0
        /*
         * private IEnumerable<TupleStruct<Kmer<Ty>, double>> ExtractUncharacteristicKmersForClass (int classIndex, MultisetKmer<Ty> thisClass, MultisetKmer<Ty> baseline)
         * {
         *      //This will only work with an enormous amount of data for low k.
         * }
         */


        //Calculation:

        //Synthesize features for an item.
        //TODO: Enforce contract
        public double[] SynthesizeFeatures(DiscreteEventSeries <Ty> item)
        {
            double[] vals = new double[kmerCount];

            MultisetKmer <Ty> ms = item.ToMultisetVarKmer <Ty>(k);

            foreach (KeyValuePair <Kmer <Ty>, int> kvp in ms)
            {
                int index = 0;
                if (kmersOntoIndex.TryGetValue(kvp.Key, out index))
                {
                    vals[index] = kvp.Value / (double)ms.Size((int)kvp.Key.Count);
                }
            }

            return(vals);
        }
Example #2
0
        /*
         * private IEnumerable<TupleStruct<Kmer<Ty>, double>> ExtractUncharacteristicKmersForClass (int classIndex, MultisetKmer<Ty> thisClass, MultisetKmer<Ty> baseline)
         * {
         *      //This will only work with an enormous amount of data for low k.
         * }
         */


        //Calculation:

        //Synthesize features for an item.
        //TODO: Enforce contract
        public double[] SynthesizeFeatures(DiscreteEventSeries <Ty> item)
        {
            double[] vals = new double[classCount];

            MultisetKmer <Ty> ms = item.ToMultisetVarKmer <Ty>(k);

            foreach (KeyValuePair <Kmer <Ty>, int> kvp in ms)
            {
                Dictionary <int, double> classesWithKvp;
                if (learnedCharacteristicKmers.TryGetValue(kvp.Key, out classesWithKvp))
                {
                    //Console.WriteLine ("\tFound kmer " + kvp.Key + ".");
                    foreach (KeyValuePair <int, double> @class in classesWithKvp)
                    {
                        //Console.WriteLine ("\t\tClass " + @class.Key + ", Value " + @class.Value + ", Times " + kvp.Value);
                        vals[@class.Key] += kvp.Value * @class.Value;
                    }
                }
            }

            return(vals);
        }