GridSearchCV and 归一化操作的使用及python实现

GridSearchCV and 归一化操作# 搜索算法最合适的参数from sklearn.model_selection import GridSearchCVfrom sklearn.metrics import classification_report# 归一化和标准化from sklearn.preprocessing import MinMaxScaler,StandardScalerimport numpy as npimport pandas as pdfrom pa
摘要由CSDN通过智能技术生成

GridSearchCV and 归一化操作

# 搜索算法最合适的参数
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import classification_report
# 归一化和标准化
from sklearn.preprocessing import MinMaxScaler,StandardScaler
import numpy as np

import pandas as pd

from pandas import Series,DataFrame

from sklearn.neighbors import KNeighborsClassifier

from sklearn.model_selection import train_test_split
cancer = pd.read_csv('C:/Users/Administrator/sklearnziliao/day2knn/day02代码/knn/cancer.csv',
                     sep = '\t')
cancer.head()
# cancer.shape
X = cancer.iloc[:,2:]
y = cancer['Diagnosis']

0      M
1      M
2      M
3      M
4      M
      ..
564    M
565    M
566    M
567    M
568    B
Name: Diagnosis, Length: 569, dtype: object
X_train,X_test,y_train, y_test = train_test_split(X, y, test_size = 0.2)

利用网格搜索算法最佳参数

--------与cross_val_score区别:gridsearchcv更集成,内部已实现for循环,crossvalscore还要自己写for循环

knn = KNeighborsClassifier()
#需调节的参数放在一个字典里
params = {
   'n_neighbors':[i for i in range
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值