Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何测试不在数据集中的图像的准确性_Python_Machine Learning_Scikit Learn_Svm_Train Test Split - Fatal编程技术网

Python 如何测试不在数据集中的图像的准确性

Python 如何测试不在数据集中的图像的准确性,python,machine-learning,scikit-learn,svm,train-test-split,Python,Machine Learning,Scikit Learn,Svm,Train Test Split,我使用train_test_split来训练和测试我的数据这是一个有趣的概念,可以将数据分为训练和测试,但是如果我想加载一些不在测试数据中的数据呢 我的问题是train_test_split只处理数据,我想看看外部图像属于哪个标签 目前,我正在从图像中提取22个特征,并使用这些特征来训练线性SVC进行识别,现在根据train_test_split,我在测试集中得到94%,这很好,我想做的只是在数据集中没有的图像上测试它。train_test_split从以前加载的数据集接收数据进行训练和测试,但

我使用train_test_split来训练和测试我的数据这是一个有趣的概念,可以将数据分为训练和测试,但是如果我想加载一些不在测试数据中的数据呢

我的问题是train_test_split只处理数据,我想看看外部图像属于哪个标签

目前,我正在从图像中提取22个特征,并使用这些特征来训练线性SVC进行识别,现在根据train_test_split,我在测试集中得到94%,这很好,我想做的只是在数据集中没有的图像上测试它。train_test_split从以前加载的数据集接收数据进行训练和测试,但我想加载映像并直接测试它们

可复制示例:(3幅图像,共10个特征)

例如,如何测试以下图像的功能

([[126., 232., 225., 149., 231., 222.,  60., 218., 152., 191.]])

所以,我要做的是选择一个特定的图像,编辑它一点,然后我想看看我的分类器在测试这个图像时是如何做的,这个图像是经过编辑的,没有经过训练的,它不在数据集中,例如,如果我从互联网上选择了一个图像,如何测试它???

如果您知道如何从图像中获取感兴趣的功能,只需加载图像,收集功能,然后根据正确的值进行预测和测试。比如说

y_test = [[1], [2], [3]]
images = # fill in however you are getting your images into memory here
clf.score(images, y_test)

# or get the predictions by hand and do your own metric
predictions = clf.predict(images)
mse = np.mean(np.square(y_test - predictions))

在执行此操作之前,您应该已经训练了分类器。

我不理解您的解决方案,如何针对未加载到数据集中的图像测试训练?你做的和我做的一样,你不必把图像加载到数据集中。例如,定义序列test_image=([[126,232,225,149,231,222,60,218,152,191.]),然后调用predicts=clf。predict(test_image)就是您所需要的全部
y_test = [[1], [2], [3]]
images = # fill in however you are getting your images into memory here
clf.score(images, y_test)

# or get the predictions by hand and do your own metric
predictions = clf.predict(images)
mse = np.mean(np.square(y_test - predictions))