参数解释,后续补上。

  1 # -*- coding: utf-8 -*-
2 """
3 ###############################################################################
4 # 作者:wanglei5205
5 # 邮箱:wanglei5205@126.com
6 # 代码:http://github.com/wanglei5205
7 # 博客:http://cnblogs.com/wanglei5205
8 # 目的:学习xgboost的XGBClassifier函数
9 # 官方API文档:http://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.training
10 ###############################################################################
11 """
12 ### load module
13 from sklearn import datasets
14 from sklearn.model_selection import train_test_split
15 from xgboost import XGBClassifier
16
17 ### load datasets
18 digits = datasets.load_digits()
19
20 ### data analysis
21 print(digits.data.shape)
22 print(digits.target.shape)
23
24 ### data split
25 x_train,x_test,y_train,y_test = train_test_split(digits.data,
26 digits.target,
27 test_size = 0.3,
28 random_state = 33)
29
30 ### fit model for train data
31 # fit函数参数:eval_set=[(x_test,y_test)] 评估数据集,list类型
32 # fit函数参数:eval_metric="mlogloss" 评估标准(多分类问题,使用mlogloss作为损失函数)
33 # fit函数参数:early_stopping_rounds= 10 如果模型的loss十次内没有减小,则提前结束模型训练
34 # fit函数参数:verbose = True True显示,False不显示
35 model = XGBClassifier()
36 model.fit(x_train,
37 y_train,
38 eval_set = [(x_test,y_test)], # 评估数据集
39
40 eval_metric = "mlogloss",
41 early_stopping_rounds = 10,
42 verbose = True)
43
44 ### make prediction for test data
45 y_pred = model.predict(x_test)
46
47 ### model evaluate
48 from sklearn.metrics import accuracy_score
49 accuracy = accuracy_score(y_test,y_pred)
50 print("accuarcy: %.2f%%" % (accuracy*100.0))
51 """
52 95.0%
53 """

【集成学习】sklearn中xgboot模块中fit函数参数详解(fit model for train data)的更多相关文章

  1. 连接池中的maxIdle,MaxActive,maxWait等参数详解

    转: 连接池中的maxIdle,MaxActive,maxWait等参数详解 2017年06月03日 15:16:22 阿祥小王子 阅读数:6481   版权声明:本文为博主原创文章,未经博主允许不得 ...

  2. linux中与Oracle有关的内核参数详解

    工作当中遇到oracle运行时CPU占用率达到90%以上,调小以下参数值后恢复正常. fs.file-max = 65536 net.core.rmem_default=262144 net.core ...

  3. C#中static void Main(string[] args) 参数详解

    学习C#编程最常见的示例程序是在控制台应用程序中输出Hello World! using System; namespace DemoMainArgs { class Program { static ...

  4. Python3 中 configparser 模块解析配置的用法详解

    configparser 简介 configparser 是 Pyhton 标准库中用来解析配置文件的模块,并且内置方法和字典非常接近.Python2.x 中名为 ConfigParser,3.x 已 ...

  5. Angular中通过$location获取地址栏的参数详解

    Angular中通过$location获取url中的参数 最近,项目开发正在进行时,心有点燥,许多东西没来得及去研究,今天正想问题呢,同事问到如何获取url中的参数,我一时半会还真没想起来,刚刚特意研 ...

  6. ajax中error函数参数详解

    xhr.status和error函数中的status是不一样的,error函数中的status主要包括:"success"."notmodified".&quo ...

  7. PHP中date函数参数详解

    date函数输出当前的时间echo date('Y-m-d H:i:s', time()); // 格式:xxxx-xx-xx xx:xx:xx 第一个参数的格式分别表示: a - "am& ...

  8. [ 原创 ]学习笔记-Android 学习笔记 Contacts (一)ContentResolver query 参数详解 [转载]

    此博文转载自:http://blog.csdn.net/wssiqi/article/details/8132603 1.获取联系人姓名 一个简单的例子,这个函数获取设备上所有的联系人ID和联系人NA ...

  9. Python3学习笔记(十一):函数参数详解

    一.位置参数 根据参数的位置来传递参数,调用函数时,传递的参数顺序和个数必须和定义时完全一致 # 定义函数 def man(name, age): print("My name is %s, ...

随机推荐

  1. C/C++ 数据类型的使用方法详解

    cppreference.com -> C/C++ 数据类型 C/C++ 数据类型 C语言包含5个基本数据类型: void, integer, float, double, 和 char. 类型 ...

  2. pyhon时间输出

    参考博客:http://www.cnblogs.com/xisheng/p/7634125.html http://www.cnpythoner.com/post/89.html 有些时候想要输出,但 ...

  3. docker学习笔记1-- 用Toolbox安装Docker--介绍Docker Machine

    使用的是Docker Toolbox,非Docker for Windows 一.docker的认识与安装(windows安装) http://blog.csdn.net/tina_ttl/artic ...

  4. windows下客户端开发hdf--环境搭建

    1.引入依赖 <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop- ...

  5. Centos7.2安装bacula及bacula-web

    serverd端安装(centos7) bacula的安装很简单,但是配置文件内容很多,配置不正确服务就启动不了,所以需要用webmin来配置. 1.安装基础软件包: 关闭SElinux(重要)set ...

  6. windows下docker toolbox无法下载boot2docker.iso

    GitHub连不上导致自动更新失败.(网络形势严峻!) 通过别的途径手动下载了指定的最新的boot2docker.iso文件.(比方说迅雷!比方说迅雷!比方说迅雷!) https://github.c ...

  7. PAT 天梯赛 L2-015. 互评成绩 【排序】

    题目链接 https://www.patest.cn/contests/gplt/L2-015 思路 在求和的过程中 标记一下 最大值和最小值,在最后求平均的时候 用总和减去最大值和最小值 去除 (总 ...

  8. arcgis flex aqi 3大util

    第一:webMapUtil 主要用来根据id或者json创建map,跟webmap相关 第二:GeometryUtil 主要用来计算面积,长度,还有判断是否相交等,跟geometry相关. 第三:We ...

  9. [POI2008]账本BBB

    题目 BZOJ 做法 明确: \(~~~1.\)为了达到目标分数所取反的次数是固定的 \(~~~2.\)为了满足前缀非负,得增加取反和滚动次数 滚动的次数可以枚举,增加的取反可以通过最小前缀和得到 滚 ...

  10. 在vim下按ctrl+s后界面卡住

    用惯了window编辑器的我们,在使用linux vim编辑器时会不会遇到这个问题:在编辑时总是会不小心按下Ctrl+S,然后整个终端都没有反应了?其实在Linux下 Ctrl+S是有特殊的用途的,不 ...