4.2 分类函数

4.2.1 MLPClassifier

MLPClassifier(hidden_layer_sizes =(100,),activation =‘relu’,solver =‘adam’,alpha = 0.0001,batch_size =‘auto’,learning_rate =‘constant’,learning_rate_init = 0.001,power_t = 0.5,max_iter = 200,shuffle = True,random_state = None,tol = 0.0001,verbose = False,warm_start = False,momentum = 0.9,nesterovs_momentum = True,early_stopping = False,validation_fraction = 0.1,beta_1 = 0.9,beta_2 = 0.999,epsilon = 1e-08 )

参数解释(Parameters):

hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)            #第i个元素表示第i个隐藏层中的神经元数量
activation : {‘identity’, ‘logistic’, ‘tanh’, ‘relu’}, default ‘relu’   #隐藏层的激活函数
solver : {‘lbfgs’, ‘sgd’, ‘adam’}, default ‘adam’                 #权重优化的求解器
learning_rate : {‘constant’, ‘invscaling’, ‘adaptive’}, default ‘constant’#学习率
max_iter:int,optional,default 200                               #最大迭代次数
early_stopping : bool, default False                               #当验证评分没有改善时,是否使用提前停止来终止培训

属性(Attributes):

classes_ : array or list of array of shape (n_classes,)  #每个输出的类标签
loss_ : float                             #使用损失函数计算的当前损失
coefs_ : list, length n_layers - 1               #列表中的第i个元素表示对应于层i的权重矩阵
intercepts_ : list, length n_layers - 1            #列表中的第i个元素表示对应于层i + 1的偏置矢量
n_iter_ : int,                             #求解器运行的迭代次数
n_layers_ : int                            #层数
n_outputs_ : int                           #输出个数
out_activation_ : string                      #输出激活功能的名称

方法(Methods):

fit(X,y)                #使模型适合数据矩阵X和目标y。
get_params([deep])          #获取此估算工具的参数。
predict(X)               #预测使用多层感知器分类器
predict_log_proba(X)         #返回概率估计的对数。
predict_proba(X)           #概率估计。
score(X,y [,sample_weight]) #返回给定测试数据和标签的平均准确度。
set_params(** PARAMS)        #设置此估算器的参数。

4.2.2 SVC

SVC(C=1.0, kernel=‘rbf’, degree=3, gamma=‘auto’, coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape=‘ovr’, random_state=None)

参数解释(Parameters):

C : float, optional (default=1.0)         # 惩罚参数C.
kernel : string, optional (default=’rbf’)  # 指定要在算法中使用的内核类型
degree : int, optional (default=3)        # 多项式核函数的次数('poly')被所有其他内核忽略
gamma : float, optional (default=’auto’)   # 'rbf','poly'和'sigmoid'的核系数

属性(Attributes):

support_ : array-like, shape = [n_SV]              # 支持向量指数
support_vectors_:array-like,shape = [n_SV,n_features] # 支持向量
n_support_:array-like,dtype = int32,shape = [n_class] # 每个类的支持向量数。
dual_coef_:array,shape = [n_class-1,n_SV]         # 决策函数中支持向量的系数
coef_:array,shape = [n_class-1,n_features]        # 赋予特征的权重(原始问题中的系数)这仅适用于线性内核
intercept_:array,shape = [n_class *(n_class-1)/ 2]  # 决策函数中的常量

方法(Methods):

decision_function(X)         #样品X到分离超平面的距离。
fit(X,y [,sample_weight])   #根据给定的训练数据拟合SVM模型。
get_params([deep])         #获取此估算工具的参数。
predict(X)               #对X中的样本进行分类。
score(X,y [,sample_weight]) #返回给定测试数据和标签的平均准确度。
set_params(** PARAMS)        #设置此估算器的参数。