-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: cluster wrong #2829
Comments
//my fixed way test pass: bool compareOriginDistance_Ascending(std::vector v0, std::vector v1)
} bool compareOriginDistance_Descending(std::vector v0, std::vector v1)
} double Vector3Distance(std::vector v0, std::vector v1)
} double Vector128Distance(std::vector v0, std::vector v1)
} unordered_map<int, std::vector> VectorGroup(std::vector<std::vector> vectors)
} std::vector<std::vector> VectorReorder(std::vector<std::vector> vectors, unordered_map<int, std::vector> groupMap)
} // ----------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////
/////// //////
} |
//improve it using namespace dlib; typedef struct _VECTOR_GROUP_T bool compareOriginDistance_Ascending(std::vector v0, std::vector v1)
} double Vector3Distance(std::vector v0, std::vector v1)
} double Vector128Distance(std::vector v0, std::vector v1)
} unordered_map<int, std::vector> getVectorMap(std::vector<std::vector> vectors)
} VECTOR_GROUP_T getVectorReorder(std::vector<std::vector> vectors, unordered_map<int, std::vector> vectorMap)
} // ----------------------------------------------------------------------------------------
///////
} |
First of all, format the code in a proper way. makes it so hard to follow. 2.) Your custom cluster algorithm is different from the Chinese cluster algorithm, why would you expect the same results? We have been using it without any problems with big data. |
#include "dlib/clustering.h" using namespace dlib; static int s_distcount = 0; bool compareOriginDistance_Ascending(std::vector v0, std::vector v1)
} double Vector3Distance(std::vector v0, std::vector v1)
} double Vector128Distance(std::vector v0, std::vector v1)
} unordered_map<int, std::vector<std::vector>> getVectorMap(std::vector<std::vector> vectorValue)
} unordered_map<int, std::vector<std::vector>> getVectorReorder(unordered_map<int, std::vector<std::vector>> vector_Map)
} // ----------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////
} |
std::vector<std::vector> vectorXYZ = These 128d vectors out from anet Chinese cluster algorithm will lost one vector into cluster that's it~ |
modify Hierarchical Clustering Agglomerative for face 128d |
////////////////////////////from chatgtp Chinese Whisper: the result same as HAC #include double euclideanDistance(std::vector& p1, std::vector& p2) { double Vector128Distance(std::vector v0, std::vector v1)
} std::vector findNeighbors(const std::vector<std::vector>& vector_XY, int index_parent, double threshold) {
} std::unordered_map<int, long> chineseWhisper(const std::vector<std::vector>& vector_XY, double threshold, int maxIterations) {
} int main() {
} //////////////////////result same as Hierarchical agglomerative clustering (HAC)
#include double euclideanDistance(std::vector& p1, std::vector& p2) { double Vector128Distance(std::vector v0, std::vector v1)
} std::vector findNeighbors(const std::vector<std::vector>& vector_XY, int index_parent, double threshold) {
} std::unordered_map<int, long> chineseWhisper(const std::vector<std::vector>& vector_XY, double threshold, int maxIterations) {
} int main() {
} //////////////////////result same as Hierarchical agglomerative clustering (HAC) ~19. {-0.0992979, 0.122165, 0.0912602, -0.0321985, -0.0684462, -0.0849711, -0.0489946, -0.135503, 0.0917729, -0.0578902, 0.272745, -0.0926052, -0.136296, -0.152289, -0.0184117, 0.0929956, -0.152167, -0.0617913, -0.0333641, 0.0428432, 0.0490224, -0.0422929, 0.0884286, 0.0014897, -0.0675949, -0.408781, -0.152954, -0.114768, 0.108607, -0.109054, -0.0608561, -0.0181542, -0.151239, -0.16152, 0.00403405, 0.0566143, -0.00598553, -0.00146211, 0.182004, -0.0298069, -0.193664, 0.0537602, 0.0379817, 0.282349, 0.214286, 0.138912, 0.0153926, -0.0876147, 0.13333, -0.127702, 0.0757071, 0.116368, 0.174625, 0.0508582, 0.0332182, -0.0451843, 0.042498, 0.0887166, -0.255065, 0.0156304, 0.135325, 0.00735303, 0.0308902, -0.0187245, 0.189613, 0.0918508, -0.0912196, -0.158444, 0.146944, -0.176383, -0.0320568, 0.020041, -0.116278, -0.137768, -0.26683, -0.00472715, 0.286731, 0.127513, -0.187165, -0.0619743, -0.14029, -0.0463117, 0.0542244, 0.0365646, -0.00987529, -0.0291819, -0.0973244, -0.0714808, 0.154462, -0.0700323, 0.015624, 0.179265, 0.0213346, 0.038605, 0.000864326, 0.0487321, -0.174079, 0.0962759, -0.133794, 0.0215799, -0.0298369, -0.0343859, 0.019338, 0.126402, -0.212536, 0.225471, -0.00803165, 0.00834702, 0.00257323, -0.0130928, -0.0553833, -0.078879, 0.123541, -0.224206, 0.203897, 0.223088, 0.0462511, 0.0959692, 0.0667733, 0.0464888, 0.0130222, 0.00502837, -0.181078, -0.0887057, 0.000660131, -0.0807323, 0.0179886, 0.022814, } ~16. {-0.128572, 0.0973682, 0.0867608, -0.0376779, -0.15026, -0.067252, -0.0249867, -0.180931, 0.111005, -0.145676, 0.274965, -0.0804217, -0.239929, -0.0838986, -0.0614532, 0.223914, -0.197584, -0.168018, -0.076038, -0.00738627, 0.0597828, -0.00679871, 0.0386248, 0.00801556, -0.0688232, -0.350878, -0.0427477, -0.0272239, -0.0232097, -0.0299352, -0.034983, 0.0572654, -0.243263, -0.106614, 0.0698775, 0.106294, -0.0264911, -0.0556516, 0.192935, -0.0870283, -0.256833, -0.00153754, 0.114026, 0.205701, 0.182697, -0.0306828, 0.00809767, -0.183568, 0.133403, -0.241614, -0.00562801, 0.149465, 0.0432816, 0.0398056, -0.0312084, -0.1105, -0.00262913, 0.174927, -0.0802645, -0.014896, 0.156133, -0.111117, -0.0773021, -0.0915959, 0.206589, 0.0374244, -0.142821, -0.158457, 0.0958246, -0.0908664, -0.0418441, 0.0285839, -0.144183, -0.185416, -0.281857, 0.0175398, 0.420626, -0.0017606, -0.182465, 0.0298958, -0.0872293, 0.0373133, 0.090707, 0.134021, 0.0284169, 0.00409463, -0.102585, 0.0471895, 0.225864, -0.117086, 0.0433835, 0.236, -0.00537327, 0.0370307, 0.0499216, 0.0921245, -0.0799572, 0.0298584, -0.191353, 0.021012, 0.0330286, -0.0616043, -0.0129402, 0.0904939, -0.146981, 0.0668456, -0.0311388, 0.0485171, 0.0754309, -0.0950844, -0.0432588, -0.13074, 0.0934741, -0.171577, 0.188043, 0.177637, 0.000807306, 0.14775, 0.122888, 0.102616, 0.0162509, 0.00551085, -0.173046, -0.0234691, 0.104719, 0.00359475, 0.0193932, -0.0480963, } ~16. {-0.090799, 0.0809553, 0.0759825, -0.0463626, -0.111534, -0.0545845, -0.0859236, -0.206957, 0.137534, -0.102071, 0.251071, -0.108932, -0.180827, -0.0782948, -0.0841926, 0.228998, -0.218102, -0.134776, -0.060099, 0.0174231, 0.0375845, -0.00156465, 0.0259291, 0.00259578, -0.0714218, -0.361112, -0.0811657, -0.0958543, 0.0238057, -0.030626, -0.0661701, 0.0917842, -0.206404, -0.0817531, 0.0562123, 0.0634374, -0.0189609, -0.0629081, 0.123064, -0.101644, -0.254773, 0.0129178, 0.0808249, 0.193162, 0.205865, 0.00972574, 0.0207571, -0.144906, 0.0755426, -0.147118, -0.0300265, 0.101131, 0.0524244, 0.0166091, 0.00339021, -0.166959, 0.00409083, 0.145328, -0.113452, -0.00029328, 0.123199, -0.126382, -0.0562261, -0.074728, 0.215938, 0.0421233, -0.10298, -0.170908, 0.145482, -0.0789228, 0.0169046, 0.0310389, -0.177285, -0.197749, -0.280558, -0.0403481, 0.383077, 0.0305359, -0.175888, 0.0779589, -0.0423169, 0.0553363, 0.095131, 0.130145, 0.0314053, 0.0128694, -0.0979745, 0.00303288, 0.176901, -0.115896, 0.0479244, 0.202174, -0.077142, -0.00887056, -0.00225188, 0.0118, -0.0701373, 0.0552305, -0.131145, -0.00932551, 0.0233421, -0.0201789, 0.00118736, 0.111896, -0.124617, 0.04992, -0.00945022, 0.0786036, 0.0560023, -0.0662577, -0.00143249, -0.11028, 0.143417, -0.19958, 0.177899, 0.182281, 0.0361073, 0.13681, 0.064873, 0.0923111, -0.00864414, 0.0141113, -0.238541, 0.0172291, 0.0908509, -0.0467091, 0.0198474, -0.00433859, } ~16. {-0.0905051, 0.00163369, 0.0535583, -0.0640821, -0.0805288, -0.0890661, -0.0340162, -0.192739, 0.164495, -0.113413, 0.233835, -0.0779192, -0.189857, -0.0858655, -0.0487517, 0.147014, -0.215897, -0.103606, -0.0712985, 0.00700117, 0.0668264, -0.0235734, 0.0690326, 0.026202, -0.115898, -0.384459, -0.112881, -0.0905679, -0.0153887, 0.0114962, -0.0201105, 0.0714012, -0.183783, -0.0746448, 0.024892, 0.0457105, -0.0202484, -0.0655856, 0.200638, -0.0854433, -0.312505, -0.00825135, 0.0735555, 0.170051, 0.175302, -0.00497253, 0.00517798, -0.129615, 0.167219, -0.142599, 0.00237514, 0.138755, 0.0646658, 0.00675762, 0.00139385, -0.0837034, 0.00909007, 0.170721, -0.144759, -0.0197719, 0.133594, -0.136821, -0.0325649, -0.0840999, 0.140316, 0.0897723, -0.101888, -0.181625, 0.128187, -0.146947, -0.003121, 0.0648141, -0.162793, -0.21874, -0.270899, -0.0528614, 0.349046, 0.0430693, -0.147338, 0.0151391, -0.0933118, 0.038197, 0.138434, 0.118174, 0.0280101, 0.0494065, -0.101154, -0.0237216, 0.215073, -0.0925647, 0.0155855, 0.242506, -0.0163804, 0.0374359, 0.0312551, 0.0249686, -0.0933276, 0.0633129, -0.158089, 0.0590632, 0.0240139, -0.0138454, 0.0238764, 0.0534265, -0.127014, 0.103142, 0.00471741, 0.0667835, 0.0666634, -0.0687426, -0.047581, -0.138089, 0.12435, -0.185108, 0.148363, 0.140487, 0.0554305, 0.150784, 0.0657144, 0.0799364, -0.0527384, -0.012457, -0.229388, 0.026468, 0.105851, -0.0175102, 0.0516422, -0.0365241, } |
modify gpt chinese whisper the answer is same HAC, not lost cluster better than HAC |
Again the algo is not wrong. However, you can modify it a bit (j = i+1 instead of i) to make sure when there is only 1 connection you guarantee the switch in the cluster id-
besides that i think there is not much point in keeping this issue open? |
//Implement Chinese Whisper algorithm in 2 points // Function to calculate the Euclidean distance between two points // Function to find the most common label in a cluster // Chinese Whispers algorithm
} int main()
} /////////////////////////////////////////////////////////////////////////////// |
full source share here |
//chineseWhisperClustering newest and test good typedef struct _VECTOR128_CAMERA_T static double Vector128Distance(std::vector v0, std::vector v1)
} // Chinese Whisper clustering algorithm implementation.
#if 1
#else
#endif
} |
What Operating System(s) are you seeing this problem on?
Linux (x86-64)
dlib version
19.24.2
Python version
3.7
Compiler
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Expected Behavior
refer to : #2821
Current Behavior
refer to : #2821
Steps to Reproduce
#include "dlib/clustering.h"
#include "dlib/string.h"
using namespace dlib;
using namespace std;
bool compareOriginDistance(std::vector v0, std::vector v1)
{
double summary;
double distance0;
double distance1;
}
double Vector3Distance(std::vector v0, std::vector v1)
{
size_t size;
size_t idx;
double summary;
double diff;
double vlen;
}
double Vector128Distance(std::vector v0, std::vector v1)
{
size_t size;
size_t idx;
double summary;
double diff;
double vlen;
}
// ----------------------------------------------------------------------------------------
int main(int argc, char** argv)
{
int count;
bool bFound;
int idx_current;
int groupIndex;
double distance;
unsigned long clusterNum;
std::unordered_map<int, std::vector> groupMap;
std::vector numlabel;
std::vector<sample_pair> numpair;
double elapsed;
struct timespec t1, t2;
/std::vector<std::vector> vectorXYZ =
{
{13.1, 13.1, 13.1}, {8.3, 8.3, 8.3}, {1.1, 1.1, 1.1}, {2.2, 2.2, 2.2}, {7, -7, 7}, {-8.2, -8.2, -8.2}, {12, 12, 12}, {7.6, 7.6, 7.6}, {13.2, 13.2, 13.2}, {13.3, 13.3, 13.3},
{8.1, 8.1, 8.1}, {1.6, 1.6, 1.6}, {2.35, 2.35, 2.35}, {7.5, -7.5, 7.5}, {-8.15, -8.15, -8.15}, {12, 12, 12}, {7.6, 7.6, 7.6}, {13, 13, 13}, {13.2, 13.2, 13.2}, {13.6, 13.6, 13.6}
};/
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
clock_gettime(CLOCK_REALTIME, &t1);
}
Anything else?
No response
The text was updated successfully, but these errors were encountered: