Xgboost GPU 加速
import xgboost as xgb
import numpy as np
from sklearn.datasets import fetch_covtype
from sklearn.model_selection import train_test_split
import time
# Fetch dataset using sklearn
cov = fetch_covtype()
X = cov.data
y = cov.target
# Create 0.75/0.25 train/test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, train_size=0.75, random_state=42)
# Specify sufficient boosting iterations to reach a minimum
num_round = 25 #3000
# Leave most parameters as default
param = {'objective': 'multi:softmax', # Specify multiclass classification
'num_class': 8, # Number of possible output classes
'tree_method': 'gpu_hist' # Use GPU accelerated algorithm
}
# Convert input data from numpy to XGBoost format
dtrain = xgb.DMatrix(X_train, label=y_train)
dtest = xgb.DMatrix(X_test, label=y_test)
gpu_res = {} # Store accuracy result
tmp = time.time()
# Train model
param['tree_method'] = 'gpu_hist'
xgb.train(param, dtrain, num_round, evals=[(dtest, 'test')], evals_result=gpu_res)
print("GPU Training Time: %s seconds" % (str(time.time() - tmp)))
[0] test-merror:0.254804
[1] test-merror:0.247885
[2] test-merror:0.24427
[3] test-merror:0.240677
[4] test-merror:0.238474
[5] test-merror:0.234763
[6] test-merror:0.232147
[7] test-merror:0.229716
[8] test-merror:0.227162
[9] test-merror:0.224622
[10] test-merror:0.222632
[11] test-merror:0.220773
[12] test-merror:0.218453
[13] test-merror:0.215582
[14] test-merror:0.214605
[15] test-merror:0.212223
[16] test-merror:0.211176
[17] test-merror:0.209868
[18] test-merror:0.208622
[19] test-merror:0.205917
[20] test-merror:0.20434
[21] test-merror:0.203727
[22] test-merror:0.202591
[23] test-merror:0.201621
[24] test-merror:0.199817
GPU Training Time: 4.505811929702759 seconds
# Repeat for CPU algorithm
tmp = time.time()
param['tree_method'] = 'hist'
cpu_res = {}
xgb.train(param, dtrain, num_round, evals=[(dtest, 'test')], evals_result=cpu_res)
print("CPU Training Time: %s seconds" % (str(time.time() - tmp)))
[0] test-merror:0.254831
[1] test-merror:0.247912
[2] test-merror:0.244298
[3] test-merror:0.24069
[4] test-merror:0.238536
[5] test-merror:0.234804
[6] test-merror:0.232229
[7] test-merror:0.229703
[8] test-merror:0.227162
[9] test-merror:0.224519
[10] test-merror:0.222784
[11] test-merror:0.220705
[12] test-merror:0.21844
[13] test-merror:0.21676
[14] test-merror:0.214736
[15] test-merror:0.212257
[16] test-merror:0.210206
[17] test-merror:0.209345
[18] test-merror:0.207617
[19] test-merror:0.206102
[20] test-merror:0.205194
[21] test-merror:0.202798
[22] test-merror:0.202309
[23] test-merror:0.200554
[24] test-merror:0.199328
CPU Training Time: 49.719186305999756 seconds
Xgboost GPU 加速的更多相关文章
- Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍
xgboost的可以参考:https://xgboost.readthedocs.io/en/latest/gpu/index.html 整体看加速5-6倍的样子. Gradient Boosting ...
- mxnet:结合R与GPU加速深度学习
转载于统计之都,http://cos.name/tag/dmlc/,作者陈天奇 ------------------------------------------------------------ ...
- GPU—加速数据科学工作流程
GPU-加速数据科学工作流程 GPU-ACCELERATE YOUR DATA SCIENCE WORKFLOWS 传统上,数据科学工作流程是缓慢而繁琐的,依赖于cpu来加载.过滤和操作数据,训练和部 ...
- Theano在windows下的安装及GPU加速
安装环境:wondows 64bit Teano安装测试 1. Anaconda 安装 Anaconda是一个科学计算环境,自带的包管理器conda很强大.之所以选择它是因为它内置了python,以及 ...
- GPU 加速NLP任务(Theano+CUDA)
之前学习了CNN的相关知识,提到Yoon Kim(2014)的论文,利用CNN进行文本分类,虽然该CNN网络结构简单效果可观,但论文没有给出具体训练时间,这便值得进一步探讨. Yoon Kim代码:h ...
- 开启gpu加速的高性能移动端相框组件!
通过设置新的css3新属性translateX来代替传统的绝对定位改变left值的动画原理,新属性translateX会开启浏览器自带的gpu硬件加速动画性能,提高流畅度从而提高用户体验, 代码有很详 ...
- ubuntu 15 安装cuda,开启GPU加速
1 首先要开启GPU加速就要安装cuda.安装cuda,首先要安装英伟达的驱动.ubuntu有自带的开源驱动,首先要禁用nouveau.这儿要注意,虚拟机不能安装ubuntu驱动.VMWare下显卡只 ...
- Silverlight - GPU加速
1. 在Silverlight plug-in上设置 <param name="enableGPUAcceleration" value="true" / ...
- 用cudamat做矩阵运算的GPU加速
1. cudamat简介 cudamat是一个python语言下,利用NVIDIA的cuda sdk 进行矩阵运算加速的库.对于不熟悉cuda编程的程序员来说,这是一个非常方便的GPU加速方案.很多工 ...
随机推荐
- CatLog_小鱼要加油
python datetime 计算时间差 面向对象:类中的特殊成员 python中字符串的拼接 Django Django中一个项目使用多个数据库 Django中cookie和session使用 在 ...
- ACC(Attribute Component Capability) 即特质,组件,能力
这是一种测试计划的替代方法. ACC的指导原则如下: 1. 避免散漫的文字,推荐使用简明的列表.并不是所有的测试人员都想当小说家,也不具备将一个产品的目标或测试需求表达成散文的技能. 2.不必推销.测 ...
- netcorec程序部署配置
IIS方式: 1:iis配置netcore发布的文件 2:iis设置运行库无托管模式 3:安装DotNetCore.1.0.4_1.1.1-WindowsHosting.exe 4:安装dotnet- ...
- xcode10对应的xcode command line tool编译的坑
众所周知,xcode10新增的编译系统new build system会不支持一些老项目的编译,一般的做法是在Xcode编译配置Xcode->File->Project Settings/ ...
- 使用LVM进行分区扩展的记录
场景:在磁盘分区空间不够的情况下,要扩展分区空间 因为使用的是虚拟机,所以可以对原有的硬盘上进行扩展,而不需要新增一个硬盘 1.扩展磁盘并使用fdisk工具进行分区 虚拟机关机后对磁盘进行扩展,扩展到 ...
- 浅析MySQL InnoDB的隔离级别
MySQL InnoDB存储引擎中事务的隔离级别有哪些?对应隔离级别的实现机制是什么? 本文就将对上面这两个问题进行解答,分析事务的隔离级别以及相关锁机制. 隔离性简介 隔离性主要是指数据库系统提供一 ...
- 使用微软自带 SharpZipLib 进行多文件 压缩
/// <summary> /// 指定路径打包下载 /// </summary> /// <param name="fileName">< ...
- ORACLE 数据库管理
[故障处理]ORA-12162: TNS:net service name is incorrectly specified 本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-1 ...
- ultiple Endpoints may not be deployed to the same path
@Configurationpublic class WebSocketConfig { //打war包启动需要注释掉此:否则报 :DeploymentException: Multiple Endp ...
- 统计Oracle一个表空间中各个segment占用的空间大小
SQL语句参考以下: select owner,segment_name,segment_type,tablespace_name,sum(bytes)/1024/1024/1024 from dba ...