二进制分类与多分类 [英] Binary Classification vs. Multi Class Classification
问题描述
我有3种可能的类别(A类,B类和C类)的机器学习分类问题.请让我知道哪种方法更好? -将问题分为2个二进制分类:首先确定是A类还是"Not A"类.然后,如果它是非A"类,则另一个二进制分类可分为B类或C类.
I have a machine learning classification problem with 3 possible classes (Class A, Class b and Class C). Please let me know which one would be better approach? - Split the problem into 2 binary classification: First Identify whether it is Class A or Class 'Not A'. Then if it is Class 'Not A', then another binary classification to classify into Class B or Class C
推荐答案
二进制分类可能最后使用sigmoid
函数(从0平滑到1).这样我们才能知道如何对两个值进行分类.
Binary classification may at the end use sigmoid
function (goes smooth from 0 to 1). This is how we will know how to classify two values.
from keras.layers import Dense
model.add(Dense(1, input_dim=8, kernel_initializer='uniform', activation='relu'))
model.add(Dense(1, kernel_initializer='uniform', activation='relu'))
model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))
对于多类分类,您通常会在最后一层使用softmax
,下一个示例中的神经元数将为10,表示10个选择.
For multi class classification you would typically use softmax
at the very last layer, and the number of neurons in the next example will be 10, means 10 choices.
from keras.layers import Dropout
model.add(Dense(512,activation='relu',input_shape=(784,)))
model.add(Dropout(0.2))
model.add(Dense(10, activation='softmax'))
但是,您也可以将softmax
与最后一层的2个神经元一起用于二进制分类:
However, you can also use softmax
with 2 neurons in the last layer for the binary classification as well:
model.add(Dense(2, activation='softmax'))
希望这对分类器没有多大帮助.
Hope this provides little intuition on classifiers.
这篇关于二进制分类与多分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!