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. selenium python自动化简明演示

    1.selenium安装: pip install -U selenium参考:https://pypi.python.org/pypi/selenium#downloads2.下载firefox驱动 ...

  2. 【二十六】php之文件编程

    1.获取文件的相关信息 fopen.fstat.fclose(打开文件.获取文件相关信息.关闭文件) filesize.filectime.filemtime.fileatime(文件大小.上次cha ...

  3. (转)为Xcode添加删除行、复制行快捷键

    转摘链接:http://www.jianshu.com/p/cc6e13365b7e 在使用eclipse过程中,特喜欢删除一行和复制一行的的快捷键.而恰巧Xcode不支持这两个快捷键,再一次的恰巧让 ...

  4. bzoj 3597: [Scoi2014]方伯伯运椰子

    Description Input 第一行包含二个整数N,M 接下来M行代表M条边,表示这个交通网络 每行六个整数,表示Ui,Vi,Ai,Bi,Ci,Di 接下来一行包含一条边,表示连接起点的边 Ou ...

  5. 我是如何确认线上CLOSE_WAIT产生的原因及如何解决的。

    1.阐述 内部架构:Tomcat应用程序---> nginx ---> 其他Tomcat应用程序,内部Tomcat应用通过nginx调用其他应用. HTTP插件:HttpClient 4. ...

  6. Oracle学习笔记_06_CASE WHEN 用法介绍

    1. CASE WHEN 表达式有两种形式 --简单Case函数 CASE sex ' THEN '男' ' THEN '女' ELSE '其他' END --Case搜索函数 CASE ' THEN ...

  7. ubuntu 安装 pythonenv

    This will get you going with the latest version of pyenv and make it easy to fork and contribute any ...

  8. detach() 与remove()

    detach() 与remove()区别,在于remove()掉后,就没有啦,添加的事件也没有啦,后者还有啊,可以保留的哦,虽然 $("div").click(function() ...

  9. promise入门demo

    <!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...

  10. Effective Java 第三版——16.在公共类中使用访问方法而不是公共属性

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...