sklearn获得某个参数的不同取值在训练集和测试集上的表现的曲线刻画
from sklearn.svm import SVC
from sklearn.datasets import make_classification
import numpy as np X,y = make_classification() def plot_validation_curve(estimator,X,y,param_name="gamma",
param_range=np.logspace(-6,-1,5),cv=5,scoring="accuracy"):
"""
描述:获得某个参数的不同取值在训练集和测试集上的表现
"""
from sklearn.model_selection import validation_curve
import matplotlib.pyplot as plt train_scores,test_scores = validation_curve(estimator=estimator,
X=X,
y=y,
cv=cv,
scoring=scoring,
param_name=param_name,
param_range=param_range) train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1) plt.title("Validation Curve")
plt.xlabel("$\gamma$")
plt.ylabel("Score")
plt.ylim(0.0, 1.1) plt.semilogx(param_range,train_scores_mean,label="Training score",color="darkorange", lw=2)
plt.fill_between(param_range,
train_scores_mean-train_scores_std,
train_scores_mean+train_scores_std,
alpha=0.2,
color="darkorange",
lw=2) plt.semilogx(param_range, test_scores_mean, label="Cross-validation score",color="navy", lw=2)
plt.fill_between(param_range,
test_scores_mean - test_scores_std,
test_scores_mean + test_scores_std,
alpha=0.2,
color="navy",
lw=2) plt.legend(loc="best")
plt.show() plot_validation_curve(estimator=SVC(),
X=X,y=y,
param_name="gamma",
param_range=np.logspace(-6,-1,5),cv=5,scoring="accuracy")
sklearn获得某个参数的不同取值在训练集和测试集上的表现的曲线刻画的更多相关文章
- sklearn不同数量的训练集在测试集上的表现的曲线刻画
def plot_learning_curve(estimator,X,y,cv=5,train_sizes=[0.1,0.3,0.5,0.7,0.8,0.9]): """ ...
- sklearn学习3----模型选择和评估(1)训练集和测试集的切分
来自链接:https://blog.csdn.net/zahuopuboss/article/details/54948181 1.sklearn.model_selection.train_test ...
- sklearn——train_test_split 随机划分训练集和测试集
sklearn——train_test_split 随机划分训练集和测试集 sklearn.model_selection.train_test_split随机划分训练集和测试集 官网文档:http: ...
- sklearn中的train_test_split (随机划分训练集和测试集)
官方文档:http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html ...
- hibernate的dao中参数的传递取值
hibernate的dao中参数的传递取值 private Query setParameter(Query query, Map<String, Object> map) { if (m ...
- loadrunner:参数类型及其取值机制
参数类型 参数名随意取,建议取通俗易懂的名字,下面我们重点介绍一下参数的类型. ●DateTime: 很简单, 在需要输入日期/时间的地方, 可以用DateTime 类型来替代. 其属性设置也很简单, ...
- fopen()函数中参数mode的取值
FILE * fopen(const char * path,const char * mode); 参数mode字符串则代表着流形态. mode有下列几种形态字符串: r 打开只读文件,该文件必须存 ...
- Sklearn分类树在合成数集上的表现
小伙伴们大家好~o( ̄▽ ̄)ブ,今天我们开始来看一下Sklearn分类树的表现,我的开发环境是Jupyter lab,所用的库和版本大家参考: Python 3.7.1(你的版本至少要3.4以上) S ...
- 使用sklearn进行数据挖掘-房价预测(2)—划分测试集
使用sklearn进行数据挖掘系列文章: 1.使用sklearn进行数据挖掘-房价预测(1) 2.使用sklearn进行数据挖掘-房价预测(2)-划分测试集 3.使用sklearn进行数据挖掘-房价预 ...
随机推荐
- 写一个简单脚本检测mysql主从是否正常
这个脚本是在从服务器上执行的 [root@bogon ~]# cat a.sh #!/bin/bash #下面这行目的在于检测mysql端口是否开启,如果没有开启,那说明mysql服务都没有开启,直接 ...
- linux面试题(自己添加了一些注释说明)
1.linux如何挂在windows下的共享目录 首先需要在Windows中创建一个文件夹用来共享,例如下面就是server是用来共享的,貌似在哪个位置创建都可以,我是在d盘创建的 1 mount.c ...
- openstack--6--控制节点和计算节点安装配置neutron
Neutron相关介绍 早期的时候是没有neutron,早期所使用的网络的nova-network,经过版本改变才有个neutron. quantum是因为商标和别的公司重名了,又改成的Neutron ...
- 99乘法表的正反写 (python的写法)
# 正写 j = 0 k = 0 while j < 10: j+=1 while k <10: k+=1 if j>k: k = 0 break else: print('{}*{ ...
- git刚初始化项目的操作
# Command line instructions ## Git global setup git config --global user.name "iback" git ...
- pip报错解决:EnvironmentError: mysql_config not found
centos7下使用python类库MySQL-python操作mysql.pip安装类库:pip install MySQL-python报错提示:mariadb EnvironmentError: ...
- Iris花逻辑回归与实现
Iris花的分类是经典的逻辑回归的代表:但是其代码中包含了大量的python库的核心处理模式,这篇文章就是剖析python代码的文章. #取用下标为2,3的两个feture,分别是花的宽度和长度: # ...
- 用shell脚本生成日志文件
mdate=`date +%R-%d-%m-%Y` LogFile=/root/HDstatusLog.log echo disk is good! $mdate >> $LogFile ...
- yii 生成条码并上传到图片服务器(zimg)
工具: 生成条码和二维码 https://github.com/codeitnowin/barcode-generator 配置:
- 【Mysql】MySQL高效获取记录总数SQL_CALC_FOUND_ROWS
用法说明 分页程序一般由两条SQL组成: SELECT COUNT(*) FROM ... WHERE .... SELECT ... FROM ... WHERE LIMIT ... 如果使用SQL ...