如何在包含1300张图片的数据集上使用 metrics.silhouette_score?我已经有了这些图片的 ResNet50 特征向量(每个长度为2048),以及1到9之间的离散类别标签?
我得到了这个错误:
Traceback (most recent call last): File "/dataset/silouhette_score.py", line 8, in <module> labels_reshaped = np.ndarray(labels).reshape(-1,1)ValueError: sequence too large; cannot be greater than 32Process finished with exit code 1
对于另一段代码:
我得到了这个错误:
Traceback (most recent call last): File "/dataset/silouhette_score.py", line 8, in <module> labels_reshaped = np.ndarray(labels).reshape(1,-1)ValueError: sequence too large; cannot be greater than 32Process finished with exit code 1
如果我运行这段其他代码:
我得到了这样的输出:https://pastebin.com/raw/hk2axdWL
如何修复这段代码,以便我可以打印出单一的轮廓分数?
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.Process finished with exit code 1
我在这里粘贴了我的特征向量文件(.txt 文件)的一行:https://pastebin.com/raw/hk2axdWL(由空格分隔的2048个数字组成)
回答:
我最终解决了这个问题。我需要以 sklearn 所要求的完全相同格式创建特征向量: