鸢尾花数据 用gridSearch做模型K近邻 svm 决策树 randomforest adaboost参数调优的练习

gridSearch做参数调优的练习 将K近邻 svm 决策树 randomforest adaboost模型的优化全都放进来

代码实现参考了这篇文章 https://blog.csdn.net/weixin_41171061/article/details/83859856

比较各种组合下分类效果最好的一个方案

用鸢尾花数据

#!/usr/bin/python
# -*- coding:utf-8 -*-
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import accuracy_score
from sklearn.metrics import auc
import numpy as np
import matplotlib as mpl
import pandas as pd
seed = 1231
np.random.seed(seed)
names = ['KNearesNeighbors','SVC','Decision Tree', 'Random Forest','AdaBoostClassifier']
classifiers = [KNeighborsClassifier(),SVC(kernel='rbf'),DecisionTreeClassifier(), RandomForestClassifier(),AdaBoostClassifier(base_estimator=DecisionTreeClassifier())]
parameter_knn = {'n_neighbors':[3,5]}
parameter_svc={'C': np.logspace(-2, 2, 10), 'gamma': np.logspace(-2, 2, 10)}
parameter_dtc = {'max_features': ['auto', 'sqrt', 'log2', None], 'max_depth': range(3, 100, 2)}
param
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值