Ejemplo n.º 1
0
        public static Vector CalculateTFIDFVector(GroupingQueryResult TargetGroup, List <GroupingQueryResult> Corpus, bool ByRawCount = false)
        {
            Vector IDFSummedVector = new DenseVector(TargetGroup.ReturnAccessVector().Count);
            Vector ReturnVector    = new DenseVector(IDFSummedVector.Count);

            Parallel.For(0, IDFSummedVector.Count, i => {
                foreach (GroupingQueryResult CurrentGQR in Corpus)
                {
                    if (CurrentGQR.GroupingName != TargetGroup.GroupingName)
                    {
                        if (CurrentGQR.ReturnAccessVector()[i] > 0)
                        {
                            IDFSummedVector[i] = IDFSummedVector[i] + 1;
                        }
                    }
                }
            });

            for (int i2 = 0; i2 < IDFSummedVector.Count; i2++)
            {
                //0.1 has been added to the denominator to prevent divide by zero issues
                IDFSummedVector[i2] = Math.Log(Corpus.Count / (IDFSummedVector[i2] + 0.1));
            }
            if (ByRawCount)
            {
                return((Vector)IDFSummedVector.PointwiseMultiply(TargetGroup.ReturnRawCountVector()));
            }
            else
            {
                return((Vector)IDFSummedVector.PointwiseMultiply(TargetGroup.ReturnAccessVector()));
            }
        }
Ejemplo n.º 2
0
 public GroupingQueryResult(GroupingQueryResult GQR) : base(GQR.ReturnAccessVector())
 {
     this.accessSummaryVector = GQR.ReturnAccessVector();
     this.rawCountVector      = GQR.ReturnRawCountVector();
     this.tF_IDFVector        = GQR.ReturnTF_IDFVector();
     this.aDGroupsRepresented = GQR.ADGroupsRepresented;
     this.groupingName        = GQR.GroupingName;
     this.groupingType        = GQR.GroupingType;
     this.groupMemberCount    = GQR.MemberCount;
     this.members             = GQR.Members;
 }