无法使用GaussianNB解释两个不同数据集上的图像识别的不同精度

问题描述

有两个表示数字0到9的图像数据集。其中一个数据集是喀拉斯语中的经典MNIST数据集,在28 * 28中具有60000个训练图像。另一个是sklearn中的数据集。这是MNIST数据集的子集,包含约600张图像。这些在8 * 8中。

在这两个数据集上都使用了非常简单的一步GaussianNB。较小的数据集具有更小的特征集64(8 * 8),给我的准确性为0.8333。但是在MNIST上使用相同的GaussianNB具有更丰富的功能集784(28 * 28)时,我的准确性仅为0.558!

尽管我知道使用CNN解决MNIST,但我实际上是在尝试了解使用GnB的这些差异很大的精度。这是什么问题?最初,较大的训练集应提供更好的准确性。当功能很多时,GnB是否会降低准确性得分?

## Using the SKlearn dataset
from sklearn.datasets import load_digits
digits = load_digits()
X = digits.data
y = digits.target
Xf = X.reshape(len(X),64) #this is an 8* 8 
#
from sklearn.model_selection import train_test_split
X_train1,X_test1,y_train1,y_test1 = train_test_split(Xf,y,random_state=0)
#
from sklearn.naive_bayes import GaussianNB
model = GaussianNB()
model.fit(X_train1,y_train1)
y_model1 = model.predict(X_test1)
#
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_model1,y_test1)
print(f"The accuracy of this model is: {accuracy}")



## Using the Keras data set
from keras.datasets import mnist
(train_images,train_labels),(test_images,test_labels) = mnist.load_data()
X_train = train_images.reshape(len(train_images),784) #this is 28 * 28
X_test = test_images.reshape(len(test_images),784)
gNB = GaussianNB()
y_model = gNB.fit(X_train,train_labels).predict(X_test)


accuracy = accuracy_score(y_model,test_labels)
print(f"The accuracy of the gNB model is: {accuracy}")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)