def parameterChoosing(self):
# Set the parameters by cross-validation
tuned_parameters = [{'penalty': ['l1'],
'C': np.logspace(-5,5)},
{'penalty': ['l2'],
'C': np.logspace(-5,5)}]
clf = GridSearchCV(linear_model.LogisticRegression(tol=1e-6), tuned_parameters, cv=5, scoring='precision_weighted')
clf.fit(self.X_train, self.y_train.ravel())
print "Best parameters set found on development set:\n"
print clf.best_params_
print "Grid scores on development set:\n"
for params, mean_score, scores in clf.grid_scores_:
print "%0.3f (+/-%0.03f) for %r\n" % (mean_score, scores.std() * 2, params)
print "Detailed classification report:\n"
y_true, y_pred = self.y_test, clf.predict(self.X_test)
print classification_report(y_true, y_pred)
ClassificationLogReg.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录