【集成学习】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, ...
随机推荐
- Django进阶项目
本来想上午轻轻松松搞定,没想到还是出了其他的问题,好在最后都解决了 在middleware.py当中 # -*- coding:utf-8 -*- __author__ = 'feimao' impo ...
- 小数据池、is 和 ==的区别
小数据池,在一定情况下出现内存共享(只有int 和 str 才有的) is 和 ==的区别 id() 打印数据的地址 a = 'hello' b = 'hello' print(a = ...
- iOS UIWindow 与 windowLevel 学习
Pop几个关键点 KeyWindow :”The key window is the one that is designated to receive keyboard and other non- ...
- ag-grid
使用: import { AgGridVue } from "ag-grid-vue"; <ag-grid-vue style="width:100%;height ...
- 【HackerRank】Maximizing XOR
给定两个整数:L 和 R ∀ L ≤ A ≤ B ≤ R, 找出 A xor B 的最大值. 输入格式 第一行包含 L 第一行包含 R 数据范围 1 ≤ L ≤ R ≤ 103 输出格式 输出最大的异 ...
- 20145210姚思羽《网络对抗》MSF基础应用实验
20145210姚思羽<网络对抗>MSF基础应用实验 实验后回答问题 1.用自己的话解释什么是exploit,payload,encode. exploit就是进行攻击的那一步 paylo ...
- JavaWeb Session
1. Session概述 1.1. 什么是Session Session一般译为会话,是解决Http协议的无状态问题的方案,可以将一次会话中的数据存储在服务器端的内存中,保证在下一次的会话中可以使用. ...
- python的一些内置函数
最近看到一些人写的文章里有提到python的描述符__get__,__set__,__del__. 这里我也小小研究了一下,除了这3个之外还加上过程中学习的几个,比如__call__等. __get_ ...
- wampserver安装缺失vcruntime140.dll
wampserver安装缺失vcruntime140.dll,这是安装wamp时候经常遇到的一个问题,对于初学者来说很难解决,以前的百度经验很难解决,所以给大家一个可以用的. 方法/步骤 请先 ...
- Java线程池ExecutorService和CountDownLatch的小例子
import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java ...