【集成学习】sklearn中xgboot模块中fit函数参数详解(fit model for train data)
参数解释,后续补上。
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)的更多相关文章
- 连接池中的maxIdle,MaxActive,maxWait等参数详解
转: 连接池中的maxIdle,MaxActive,maxWait等参数详解 2017年06月03日 15:16:22 阿祥小王子 阅读数:6481 版权声明:本文为博主原创文章,未经博主允许不得 ...
- linux中与Oracle有关的内核参数详解
工作当中遇到oracle运行时CPU占用率达到90%以上,调小以下参数值后恢复正常. fs.file-max = 65536 net.core.rmem_default=262144 net.core ...
- C#中static void Main(string[] args) 参数详解
学习C#编程最常见的示例程序是在控制台应用程序中输出Hello World! using System; namespace DemoMainArgs { class Program { static ...
- Python3 中 configparser 模块解析配置的用法详解
configparser 简介 configparser 是 Pyhton 标准库中用来解析配置文件的模块,并且内置方法和字典非常接近.Python2.x 中名为 ConfigParser,3.x 已 ...
- Angular中通过$location获取地址栏的参数详解
Angular中通过$location获取url中的参数 最近,项目开发正在进行时,心有点燥,许多东西没来得及去研究,今天正想问题呢,同事问到如何获取url中的参数,我一时半会还真没想起来,刚刚特意研 ...
- ajax中error函数参数详解
xhr.status和error函数中的status是不一样的,error函数中的status主要包括:"success"."notmodified".&quo ...
- PHP中date函数参数详解
date函数输出当前的时间echo date('Y-m-d H:i:s', time()); // 格式:xxxx-xx-xx xx:xx:xx 第一个参数的格式分别表示: a - "am& ...
- [ 原创 ]学习笔记-Android 学习笔记 Contacts (一)ContentResolver query 参数详解 [转载]
此博文转载自:http://blog.csdn.net/wssiqi/article/details/8132603 1.获取联系人姓名 一个简单的例子,这个函数获取设备上所有的联系人ID和联系人NA ...
- Python3学习笔记(十一):函数参数详解
一.位置参数 根据参数的位置来传递参数,调用函数时,传递的参数顺序和个数必须和定义时完全一致 # 定义函数 def man(name, age): print("My name is %s, ...
随机推荐
- python常用模块-1
一.认识模块 1.什么是模块:一个模块就是一个包含了python定义和声明的文件,文件名就是加上.py的后缀,但其实import加载的模块分为四个通用类别 : 1.使用python编写的代码(.py文 ...
- Android开发问题:ActivityNotFoundException: Unable to find explicit activity class
http://blog.csdn.net/debuglog/article/details/7236013 原因:AndroidManifest.xml未添加对应Activity配置. 解决办法:在A ...
- PHP领域类型Java中ibatis的API
最近公司技术调整,要把java用php换掉,其中java主要的工作就是查询数据库,并返回json,ORM用的是ibatis,主要用到了Object映射和动态SQL,组员们用的都挺6,转到PHP后,发现 ...
- 生成sql表结构
DataConstruct.php <?php /** * Created by PhpStorm. * User: Administrator * Date: 2017/7/21 * Time ...
- P3413 SAC#1 - 萌数
题目 洛谷 数位动规用爆搜真好玩 做法 含有回文串实际我们仅需判断是否有\(2/3\)回文串 \(Dfs(now,num,pre,ly,lead,prel,top)\): 在第\(now\)位 \(n ...
- CSS3透明背景表单
在线演示 本地下载
- block(data block,directory block)、inode、块位图、inode位图和super block概念详解【转】
本文转载自:https://blog.csdn.net/jhndiuowehu/article/details/50788287 一.基本概念: 1.block:文件系统中存储数据的最小单元 ...
- Linux基本常用命令
说到Linux,它就是基于POSIX和UNIX的多用户,多任务,支持多线程和多CPU的操作系统.它能运行主要的UNIX的工具软件,应用程序和网络协议.它支持32位和64位硬件.linux继承Unix以 ...
- spark学习5(hbase集群搭建)
第一步:Hbase安装 hadoop,zookeeper前面都安装好了 将hbase-1.1.3-bin.tar.gz上传到/usr/HBase目录下 [root@spark1 HBase]# chm ...
- HRBUST 1717 字典树模板
之前写字典树虽然很熟也能变化 但是一直是到了场上再乱写 写的很长 于是准备写个短点的板子 于是选了个水题 然而写出了1W个bug insert和query反而写的没什么问题.. L c[100050] ...