Using sklearn to design "optimal" classifiers for the handwritten digits dataset and the iris dataset

Problem Description

提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加
Through experimental methods (classifier type selection, optimization method, activation function), design an "optimal" classifier for the handwritten digits dataset and the iris dataset


欢迎大家交流技术,如果有任何问题可以私聊我,期待你们的关注

method

I use three classifiers: SVM, MLP, and SGD, and specify different parameters for each classifier. SVM sets different kernel parameter values, including 'linear', 'poly', 'rbf', 'sigmoid'; MLP Set different solver optimizers, including 'adam', 'lbfgs', 'sgd', activation activation functions include 'tanh', 'relu', 'logistic', 'identity'; SGD sets different losses including 'hinge', 'log', 'modified_huber', 'squared_hinge', 'perceptron'. Then classify and test the data sets of handwritten digits for these different classifiers, judge the performance of each classifier according to the accuracy of the test, put the accuracy of each classifier into a dictionary, and the key of the dictionary is the classification The name of the classifier, the value of the dictionary is the accuracy rate corresponding to the classifier, and finally the best classifier and its accuracy rate are obtained.

optim = ['adam', 'lbfgs', 'sgd']
act = ['tanh', 'relu', 'logistic', 'identity']
ker = ['linear', 'poly', 'rbf', 'sigmoid']
opt = ['hinge', 'log', 'modified_huber', 'squared_hinge', 'perceptron']

Result display

After experimental verification, the use of SVM and the sum function of rbf can obtain the final classification accuracy rate of 98.9% on the data set of handwritten digit recognition.
insert image description here

For the iris data set, classifiers with better performance include MLP using adam's optimizer and logistic activation function, MLP using adam's optimizer and tanh activation function, MLP using adam's optimizer and identity activation function, MLP uses sgd optimizer and tanh activation function, MLP uses sgd optimizer and identity activation function, MLP uses lbfgs optimizer and identity activation function classifier, these can make the accuracy rate reach 100%.

insert image description here

The performance of classifiers for different data sets is different, and it is necessary to experiment with data sets in different situations to obtain the optimal classifier parameters.

Guess you like

Origin blog.csdn.net/qq_48068259/article/details/127880850