Exemple #1
0
        public static void jacSplitTest(string inputData, string outputPath="jac_result.txt")
        {
            int[] ui = cleanLogsj(inputData);
            Console.WriteLine("numUser:{0}\tnumIntent:{1}", ui[0], ui[1]);
            split("jac_usi_processed.log");
            JACMatrix testMat = makeUtilMat(ui[1], ui[0], "jac_test.log");
            JACMatrix traintMat = makeUtilMat(ui[1], ui[0], "jac_train.log");
            JACCF filter = new JACCF(traintMat, false, 5, 10, false);
            int[] final = new int[4] { 0, 0, 0, 0 };
            Parallel.For<int[]>(0, ui[0],
                                () => new int[4] { 0, 0, 0, 0 },
                                (user, state, stats) =>
                                {
                                    for (int intent = 0; intent < ui[1]; intent += 1)
                                    {
                                        Double trueVal = testMat.get(intent, user);
                                        Double predictedVal = filter.predict(intent, user);
                                        if (trueVal == predictedVal && trueVal == 1)
                                            stats[0]++;
                                        else if (trueVal == predictedVal && trueVal == 0)
                                            stats[1]++;
                                        else if (trueVal == 1)
                                            stats[3]++;
                                        else
                                            stats[2]++;
                                        Console.WriteLine("truePos:{0}\ttrueNeg:{1}\tfalsePos:{2}\tfalseNeg:{3}", stats[0], stats[1], stats[2], stats[3]);
                                    }
                                    return stats;
                                },
                                 (stats) =>
                                 {
                                     lock (final)
                                     {
                                         final[0] += stats[0];
                                         final[1] += stats[1];
                                         final[2] += stats[2];
                                         final[3] += stats[3];
                                     }
                                 });

            Console.WriteLine("truePos:{0}\ttrueNeg:{1}\tfalsePos:{2}\tfalseNeg:{3}", final[0], final[1], final[2], final[3]);
            StreamWriter writer = new StreamWriter(outputPath);
            writer.WriteLine("truePos:{0}\ttrueNeg:{1}\tfalsePos:{2}\tfalseNeg:{3}", final[0], final[1], final[2], final[3]);
        }
Exemple #2
0
        private Dictionary<int, int>[] sigMat; //gets hash value from column

        #endregion Fields

        #region Constructors

        public JACLSH(JACMatrix utilMat, int r, int b, JACCF filter)
        {
            this.filter = filter;
            this.numSets = utilMat.GetLength(1);
            this.r = r;
            this.b = b;
            sigMat = new Dictionary<int, int>[b];
            revSigMat = new MultiDictionary<int, int>[b];
            for (int bandInd = 0; bandInd < b; bandInd++)
            {
                sigMat[bandInd] = new Dictionary<int, int>();
                revSigMat[bandInd] = new MultiDictionary<int, int>(true);
            }
            compSigMatEntries(utilMat);
        }