I am using k-fold cross validation for hyperparameter tuning on the whole training set with Weka and it shows the average precision, recall, f1 of cross validation. I want to get the same results with Sklearn in python.
cv = StratifiedShuffleSplit(n_splits=5, test_size=0.2, random_state=42)
grid = GridSearchCV(LinearSVC(), param_grid=param_grid, cv=cv)
grid.fit(X_train, y_train)
# print the best parameters
print("The best parameters are %s with a score of %0.5f"
% (grid.best_params_, grid.best_score_))
# print the average precision, recall, f1, accuracy of cross
# validation with the best parameters found
???
Anyone can help?
You can use the classification_report
function from sklearn.metrics
.
http://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.