一.linear_model
1.简介:
该模块实现了各种"线性模型"(linear models)
2.线性分类器(Linear classifiers):
"逻辑回归分类器"(Logistic Regression classifier):class sklearn.linear_model.LogisticRegression([penalty='l2',dual=False,tol=0.0001,C=1.0,fit_intercept=True,intercept_scaling=1,class_weight=None,random_state=None,solver='lbfgs',max_iter=100,multi_class='auto',verbose=0,warm_start=False,n_jobs=None,l1_ratio=None])
#参数说明:
penalty:指定使用的范数惩罚正则项;为"L1"/"L2"/"elasticnet"/"none"
dual:指定是否进行对偶化;为bool
tol:指定最小误差(若误差小于该值,则停止);为float
C:指定"正则化强度"(regularization strength)的倒数;为float>0
#即范数惩罚正则化项前系数的倒数
fit_intercept:指定是否估计截距;为bool
intercept_scaling:为float
Useful only when the solver 'liblinear' is used and self.fit_intercept is set to True. In this case, x becomes
[x, self.intercept_scaling], i.e. a 'synthetic' feature with constant value equal to intercept_scaling is
appended to the instance vector. The intercept becomes intercept_scaling * synthetic_feature_weight
#注意:the synthetic feature weight is subject to l1/l2 regularization as all other features. To lessen the effect
# of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be
# increased
class_weight:指定各个类别的权重;为dict/"balanced"
random_state:指定使用的随机数;为int/RandomState instance/None
solver:指定用于优化的算法;为"newton-cg"/"lbfgs"/"liblinear"/"sag"/"saga"
max_iter:指定最大迭代次数;为int
multi_class:指定如何处理多类别分类问题;为"auto"/"ovr"/"multinomial"
verbose:指定输出信息的冗余度;为int/bool
warm_start:指定是否启用热启动;为bool
n_jobs:指定用于并行计算的CPU核心数;为int
l1_ratio:指定"弹性网络混合参数"(Elastic-Net mixing parameter);为float
#用于控制L1/L2惩罚项的占比,l1_ratio=0相当于penalty="l2",而l1_ratio=1相当于penalty="l1"
######################################################################################################################
进行了"交叉验证"(cross-validation)的逻辑回归分类器:class sklearn.linear_model.LogisticRegressionCV([Cs=10,fit_intercept=True,cv=None,dual=False,penalty='l2',scoring=None,solver='lbfgs',tol=0.0001,max_iter=100,class_weight=None,n_jobs=None,verbose=0,refit=True,intercept_scaling=1.0,multi_class='auto',random_state=None,l1_ratios=None])
#参数说明:其他参数同class sklearn.linear_model.LogisticRegression()
Cs:功能同class sklearn.linear_model.LogisticRegression()的参数C;为int/float list
cv:指定交叉验证的拆分策略;为int/cross-validation generator
scoring:指定如何打分;为str/callable
refit:If set to True,the scores are averaged across all folds,and the coefs and the C that corresponds to the best score is taken,and a final refit is done using these parameters
Otherwise the coefs, intercepts and C that correspond to the best scores across folds are averaged
######################################################################################################################
"被动攻击性分类器"(Passive Aggressive Classifier;PA Classifier):class sklearn.linear_model.PassiveAggressiveClassifier([C=1.0,fit_intercept