I’ve been trying to implement my base paper which is about community detection using deep learning for more than a year. In this paper Crow Search Algorithm and kmeans have been used but I can’t figure out how to implement it correctly.
Link to download the paper
As I understand the paper follows these steps to implement Crow Search:
- creating an initial population
- pass positions to fitness function
- calculate nmi for positions (with ground truth labels, I have ground truths for datasets in the paper)
- return positions with best nmi scores
- find best positions
- pass best positions to kmeans to use as centroids
- kmeans finds final result (which are communities)
When I tried to implement this part, after position passed to fitness function (step 2), nmi can’t be calculated (step 3), because created initial population are not discrete numbers but ground truths are discrete. I don’t know how to fix it.
Chat GPT suggests to use kmeans here in fitness function, then calculate nmi using kmeans resualts.
This way I have to use kmeans in two different places, one in fitness function and two at the very end of the code to find final communities.
I tried this solution but at the end I don’t get correct answers. Four metrics must be calculated after final communities are found: NMI, Precision, Recall and Modularity matrix, but I could not get the right answer same as tables in the paper.
What is the correct solution? If you understand the paper please explain it to me.
If anyone could help me with this I’d appreciate it. I’m short in time and have no clue at all.
I tried every way I could think of and used GPT for help but didn’t work.
I even paid money to someone to implement this code for me but they just gave me some completely incorrect implementations and wasted my time and never returned my money.
So if anyone here could help me with this I’d don’t know how to thank them.
(Edit. Here is the algorithm according to page 9.)
Input: S : Flock Size,
d : number of dimensions,
F : Set of all possible solutions and values,
itermax : Max number of iterations,
fl : flight length,
AP : Awareness probability
Output: Optimal positions
1: crowPositions ← InitializeRandomPosition(d, F, S)
2: Memory ← InitializeMemory(d, F, S)
3: Fitness ← CalculateFitness(CrowPositions)
4: score ← NMIscore(ActualLabels, PredictedClusterLabels)
5: while k < itermax
6: for i ← 1 to S
7: ri ← GenerateRandom()
8: RandomCrow ← ChooseRandomCrow(S)
9: NewPosn ← UpdatePosn(CrowPositions, i, Memory, RandomCrow, AP, ri)
10: endfor
11: if NewPosn ∈ F
12: CrowPostions ← NewPosn
13: endif
14: NewFitness ← CalculateFitness(CrowPostions)
15: if NewFitness > Fitness
16: Memory ← CrowPostions
17: endif
18: k ← k + 1
19: endwhile
20: return crow position with best fitness out of all CrowPostions
1