GridSearchCV

详细地址:http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.GridSearchCV.html#examples-using-sklearn-grid-search-gridsearchcv

具体实例:

# -*- coding: utf-8 -*-
"""
Created on Mon Jun 15 15:30:30 2015 @author: Chaofn
"""
import numpy as np
from sklearn import datasets
from sklearn import cross_validation
from sklearn.svm import SVR
from sklearn.grid_search import GridSearchCV
#Laod sample data
boston=datasets.load_boston()
"""
We can now quickly sample a training set while holding out 40% of
the data for testing (evaluating) our predictor
"""
x_train,x_test,y_train,y_test=cross_validation.train_test_split(
boston.data,boston.target,test_size=0.3,random_state=0)
#Fit regression model
svr=GridSearchCV(SVR(kernel='rbf',gamma=0.1),cv=5,
param_grid={"C":[1e0,1e1,1e2,1e3],
"gamma":np.logspace(-2,2,5)})
svr.fit(x_train,y_train)
#Predict
predict_targets=svr.predict(x_test)
#Evalution
n_test_samples=len(y_test)
error=np.linalg.norm(predict_targets-y_test,ord=1)/n_test_samples
print("Mean Absolute Error is:%.3f" %(error))
pcc=np.corrcoef(predict_targets,y_test)[0,1]
print ("Pearson Correlation Coefficient: %.4f" %(pcc))

grid搜索最优参数的更多相关文章

  1. 吴裕雄 python 机器学习——模型选择参数优化暴力搜索寻优GridSearchCV模型

    import scipy from sklearn.datasets import load_digits from sklearn.metrics import classification_rep ...

  2. Elasticsearch搜索调优权威指南 (2/3)

    本文首发于 vivo互联网技术 微信公众号 https://mp.weixin.qq.com/s/AAkVdzmkgdBisuQZldsnvg 英文原文:https://qbox.io/blog/el ...

  3. Elasticsearch搜索调优权威指南 (1/3)

    本文首发于 vivo互联网技术 微信公众号 https://mp.weixin.qq.com/s/qwkZKLb_ghmlwrqMkqlb7Q英文原文:https://qbox.io/blog/ela ...

  4. JVM调优参数、方法、工具以及案例总结

    这种文章挺难写的,一是JVM参数巨多,二是内容枯燥乏味,但是想理解JVM调优又是没法避开的环节,本文主要用来总结梳理便于以后翻阅,主要围绕四个大的方面展开,分别是JVM调优参数.JVM调优方法(流程) ...

  5. Dubbo性能调优参数及原理

    本文是针对 Dubbo 协议调用的调优指导,详细说明常用调优参数的作用域及源码. Dubbo调用模型 常用性能调优参数 参数名 作用范围 默认值 说明 备注 threads provider 200 ...

  6. Spring Cloud 各组件调优参数

    Spring Cloud整合了各种组件,每个组件往往还有各种参数.本文来详细探讨Spring Cloud各组件的调优参数. Tomcat配置参数 1 server: 2 tomcat: 3 max-c ...

  7. Linux TCP/IP调优参数 /proc/sys/net/目录

    所有的TCP/IP调优参数都位于/proc/sys/net/目录. 例如, 下面是最重要的一些调优参数,后面是它们的含义: /proc/sys/net/core/rmem_default " ...

  8. hadoop作业调优参数整理及原理

    hadoop作业调优参数整理及原理 10/22. 2013 1 Map side tuning参数 1.1 MapTask运行内部原理 当map task开始运算,并产生中间数据时,其产生的中间结果并 ...

  9. 量化编程技术—itertools寻找最优参数

    # -*- coding: utf-8 -*- # @Date: 2017-08-26 # @Original: ''' 在量化数据处理中,经常使用itertools来完成数据的各种排列组合以寻找最优 ...

随机推荐

  1. iOS Xcode及模拟器SDK下载

    原文: Xcode及模拟器SDK下载 如果你嫌在 App Store 下载 Xcode 太慢,你也可以选择从网络上下载: Xcode下载(Beta版打的包是不能提交到App Store上的) 绝对官方 ...

  2. 自定义结构化config文件

    前言 开发过程中我们会经常使用到各种config文件,经常我们会使用appSettings进行设置所用的配置,但是随着配置量的增多,都放在appSettings里面明显是不合适的,一方面配置容易混乱, ...

  3. iView的使用【小白向】

    首先看这篇:构建Vue本地开发环境(现阶段还不知道怎么用CDN的方式做...) 安装iView(WindowsPowershell或cmd下用cnpm) 编辑上一篇博客创建的Vue工程 先到main. ...

  4. HTML5学习知识点

    一.文档问题 1.html5新标签:section.header.footer.nav.aside.blockquote.q.fieldest.figure.address.article.detai ...

  5. 关于foo的一个面试题

    今天看到一个关于foo的一个面试题,赶脚特别有意思 function foo(){// 第16行 getName = function(){console.log(1)} return this } ...

  6. Cleaner, more elegant, and wrong(msdn blog)

    Cleaner, more elegant, and wrong Just because you can't see the error path doesn't mean it doesn't e ...

  7. (转) Linux中profile、bashrc、bash_profile之间的区别和联系

    原文地址:http://blog.csdn.net/chenchong08/article/details/7833242 /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登 ...

  8. 中文代码示例之Vuejs入门教程(一)

    原址: https://zhuanlan.zhihu.com/p/30917346 为了检验中文命名在主流框架中的支持程度, 在vuejs官方入门教程第一部分的示例代码中尽量使用了中文命名. 所有演示 ...

  9. 2、公司部门的组成 - CEO之公司管理经验谈

    今天讲讲公司部门的组成.公司部门一般是根据公司业务来进行划分的,IT企业和其它企业的部门划分有一定的区别.企业部门的划分还是比较重要的,部门主要明确各部门所具有的自己的职责.这里对IT企业的部门做了一 ...

  10. vue2.0表单事件的绑定

    v-model 1.input type="text" <template> <div id="app"> <label for= ...