Home > Net > An example of c # calculation duplication for help like sea quantity data
An example of c # calculation duplication for help like sea quantity data
Time:11-10
Good the great god ~
I have an example of calculating the duplication:
Outer loop has 1000, data of List , concrete is 1,2,4,7,13 inside such Numbers, length of uncertain Circulate in 300000, the data for List , there is 1,2,3,7,29 such Numbers, length is 6
Yourself with the following algorithm, c # for each combination of calculate can repeat degree,
List ListA=new List (a); ListA=XXX;//here to listA initialization 1000 digital string
List ListListB=new List (a); ListListB=XXX;//here to listA initialization 300000 digital string
{foreach (var itemA in listA) The foreach (var itemB listListB) in { Int CFD=getcfd (itemA, itemB) } }
Add a method Int getcfd (list Lista, list By) { Int CFD=0; The foreach (var itemINT lista) in { If (by the contains (itemINT) cfd++; } The return of CFD; }
The above calculation, the whole process is too time consuming, I checked the Internet, according to the two layers of loop optimized code, there is no obvious change, then the getcfd method instead of the dictionary can either containsKey slightly better,
Behold a great god, and can cut down the calculation time, Algorithm structure, for example, can reduce the time complexity, Is the use of multithreading, for example, caching, reduce calculation times,
CodePudding user response:
Cosine similarity?
CodePudding user response:
Don't know you specific scenarios, cosine ignore the distance is only See your original algorithm, seems to want to calculate proportion
Personally, I think you can take the maximum and minimum out, no intersection directly through
Or first than cosine characteristics, cosine approximation in than European feature