第69集 python机器学习:网格搜索预处理及其模型选择( 七 )

grid.fit(x_train y_train)

print(\"Best parameters: {\".format(grid.best_params_))

#打印出最佳参数的分数

print(\"Best score with coss validation : {:.3f\".format(grid.best_score_))

print(\"Best test-score: {:.3f\".format(grid.score(x_test y_test)))

运行后其对应结果为:

Best parameters: {'classifier': SVC(C=10 cache_size=200 class_weight=None coef0=0.0

decision_function_shape='ovr' degree=3 gamma=0.01 kernel='rbf'

max_iter=-1 probability=False random_state=None shrinking=True

tol=0.001 verbose=False) 'classifier__C': 10 'classifier__gamma': 0.01 'preprocessing': StandardScaler(copy=True with_mean=True with_std=True)

推荐阅读