参数解释,后续补上。

  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. XSS - html过滤

    JS 根据白名单过滤HTML http://jsxss.com/zh/index.html   方案一: java的一个方案, 可以参考:  http://winnie825.iteye.com/bl ...

  2. JavaScript:学习笔记(3)——正则表达式的应用

    JavaScript:正则表达式的应用 应用正则表达式对象RegExp 创建正则表达式 JavaScript中使用RegExp对象来表述一个正则表达式.使用正则表达式之前首先要创建一个RegExp对象 ...

  3. Andorid:日常学习笔记(3)——掌握日志工具的使用

    Andorid:日常学习笔记(3)——掌握日志工具的使用 使用Android的日志工具Log 方法: Android中的日志工具类为Log,这个类提供了如下方法来供我们打印日志: 使用方法: Log. ...

  4. Python学习进程(3)Python基本数据类型

        本节介绍在Python语法中不同的变量数据类型.     (1)基本数据类型: >>> a=10; >>> b=10.0; >>> c=T ...

  5. $Android AlertDialog的各种用法总结

    Refer:http://www.2cto.com/kf/201205/131876.html (一)最简单的用法(详见注释) 1 // 1.创建简单的AlertDialog // AlertDial ...

  6. Python编程-常用模块及方法

    常用模块介绍 一.time模块 在Python中,通常有这几种方式来表示时间: 时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量.我们运行 ...

  7. Go 外部排序-网络版

    目录结果 main.go package main import ( "NetworkSort/pipeline" "fmt" "os" & ...

  8. JMeter学习(七)聚合报告之 90% Line 正确理解

    90% Line 参数正确的含义: 虽然,我的上面理解有一定的道理,显然它是错误的.那看看JMeter 官网是怎么说的? 90% Line - 90% of the samples took no m ...

  9. 搭建本地yum源服务器

    搭建本地yum源服务器   好久没写博客了,最近比较动荡,临毕业时跳了个槽,感觉之前做的金融方向的运维不是很适合我,对各方面的限制还是太多.金融的IT对于安全似乎要求很高,云盘,U盘都不能用,还要经常 ...

  10. SQL中的5种常用的聚集函数

    首先你要知道 where->group by->having->order by/limit  ,这个就是写sql语句时的顺序  常用的5个聚集函数: Max             ...