重塑您的数据,如果您的数据只有一个特征,请使用 array.reshape(-1, 1)

如何在包含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 所要求的完全相同格式创建特征向量:

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注