1. 回归

scikit-learn中关于回归有好多方法

1. Logistic Regression

LR模型在scikit-learn中至少有两处可以用:

① 在SGDClassifier中:

文档地址:SGDClassifier

from sklearn.linear_model import SGDClassifier
clf = SGDClassifier(loss = 'log', penalty = 'l2')
clf.fit(train_x, train_y)	# x is like-array type, shape = [numSamples, numFeatures], y is like-array type
pred_y = clf.predict(test_x)	# return numpy.ndarray type
print clf.coef_		# 打印参数
print clf.intercept_	# 打印截距项

 
 

② 在LogisticRegression中:

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(penalty = 'l2')
clf.fit(train_x, train_y)	# x is like-array type, shape = [numSamples, numFeatures], y is like-array type
pred_y = clf.predict(test_x)	# return numpy.ndarray type
print clf.coef_		# 打印参数
print clf.intercept_	# 打印截距项





你可能感兴趣的:(1. 回归)