# -*- coding: utf-8 -*-
"""
Created on Wed Sep 6 14:30:24 2017
@author: 飘的心
"""
from sklearn.datasets import load_digits
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
from sklearn import metrics
data=load_digits()
x=data.data
y=data.target
x_train,x_test,y_train,y_test=train_test_split(x,y,random_state=0,test_size=0.25,
stratify=y)
#采用暴力搜索,所有参数进行组合,然后选择最好的参数
tuned_parameters=[{'penalty':['l1','l2'],
'C':[0.01,0.05,0.1,0.5,1,5,10,50,100],
'solver':['liblinear'],
'multi_class':['ovr']},
{'penalty':['
Python进行参数调优GridSearchCV和RandomizedSearchCV
最新推荐文章于 2024-08-15 09:37:31 发布