xgboost安装/git操作

来源:互联网 发布:老版书旗小说软件 编辑:程序博客网 时间:2024/06/06 10:47

xgboost安装

windows安装xgboost库

方法一(推荐):

该链接下载已经编译好的xgboost库https://github.com/icepoint666/MachineLearning/tree/master/MachineLearning/xgboost

解压后,在该文件夹python-package路径下输入

python setup.py install

import xgboost验证是否安装成功

方法二:

1. 首先将xgboost克隆到本地

     ​git clone --recursive https://github.com/dmlc/xgboost

本地版本控制系统:采用某种简单的数据库来记录文件的历次更新差异。

这里写图片描述

集中化的版本控制系统(Centralized Version Control Systems,简称 CVCS): 这类系统,诸如 CVS、Subversion(SVN) 以及 Perforce 等,都有一个单一的集中管理的服务器,保存所有文件的修订版本,而协同工作的人们都通过客户端连到这台服务器,取出最新的文件或者提交更新。

这里写图片描述

分布式版本控制系统(Distributed Version Control System,简称 DVCS):在这类系统中,像 Git、Mercurial、Bazaar 以及 Darcs 等,客户端并不只提取最新版本的文件快照,而是把代码仓库完整地镜像下来。 这么一来,任何一处协同工作用的服务器发生故障,事后都可以用任何一个镜像出来的本地仓库恢复。 因为每一次的克隆操作,实际上都是一次对代码仓库的完整备份。

这里写图片描述

1)git clone命令

用于克隆远程存储库

1.先创建一个存储库目录,在此目录右键git bash

这里写图片描述

弹出git命令行

这里写图片描述

输入以下命令

$ git clone http://git.oschina.net/yiibai/sample.git

还可以配置参数,例如–recursive,作用:initialize submodules in the clone

$ git clone --recursive https://github.com/dmlc/xgboost

这些链接一般可以在网上仓库找到

2)git常用操作,实际上是linux命令

系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年.秒 clock -w 将时间修改保存到 BIOS 
文件和目录 cd /home 进入 '/ home' 目录' cd .. 返回上一级目录 cd ../.. 返回上两级目录 cd 进入个人的主目录 cd ~user1 进入个人的主目录 cd - 返回上次所在的目录 pwd 显示工作路径 ls 查看目录中的文件 ls -F 查看目录中的文件 ls -l 显示文件和目录的详细资料 ls -a 显示隐藏文件 ls *[0-9]* 显示包含数字的文件名和目录名 tree 显示文件和目录由根目录开始的树形结构(1) lstree 显示文件和目录由根目录开始的树形结构(2) mkdir dir1 创建一个叫做 'dir1' 的目录' mkdir dir1 dir2 同时创建两个目录 mkdir -p /tmp/dir1/dir2 创建一个目录树 rm -f file1 删除一个叫做 'file1' 的文件' rmdir dir1 删除一个叫做 'dir1' 的目录' rm -rf dir1 删除一个叫做 'dir1' 的目录并同时删除其内容 rm -rf dir1 dir2 同时删除两个目录及它们的内容 mv dir1 new_dir 重命名/移动 一个目录 cp file1 file2 复制一个文件 cp dir/* . 复制一个目录下的所有文件到当前工作目录 cp -a /tmp/dir1 . 复制一个目录到当前工作目录 cp -a dir1 dir2 复制一个目录 ln -s file1 lnk1 创建一个指向文件或目录的软链接 ln file1 lnk1 创建一个指向文件或目录的物理链接 touch -t 0712250000 file1 修改一个文件或目录的时间戳 - (YYMMDDhhmm) file file1 outputs the mime type of the file as text iconv -l 列出已知的编码 iconv -f fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding. find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick) 
文件搜索 find / -name file1 从 '/' 开始进入根文件系统搜索文件和目录 find / -user user1 搜索属于用户 'user1' 的文件和目录 find /home/user1 -name \*.bin 在目录 '/ home/user1' 中搜索带有'.bin' 结尾的文件 find /usr/bin -type f -atime +100 搜索在过去100天内未被使用过的执行文件 find /usr/bin -type f -mtime -10 搜索在10天内被创建或者修改过的文件 find / -name \*.rpm -exec chmod 755 '{}' \; 搜索以 '.rpm' 结尾的文件并定义其权限 find / -xdev -name \*.rpm 搜索以 '.rpm' 结尾的文件,忽略光驱、捷盘等可移动设备 locate \*.ps 寻找以 '.ps' 结尾的文件 - 先运行 'updatedb' 命令 whereis halt 显示一个二进制文件、源码或man的位置 which halt 显示一个二进制文件或可执行文件的完整路径 

3)git submodule

用于初始化,更新或检查子模块

git submodule [--quiet] add [<options>] [--] <repository> [<path>]git submodule [--quiet] status [--cached] [--recursive] [--] [<path>…​]git submodule [--quiet] init [--] [<path>…​]git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>…​)git submodule [--quiet] update [<options>] [--] [<path>…​]git submodule [--quiet] summary [<options>] [--] [<path>…​]git submodule [--quiet] foreach [--recursive] <command>git submodule [--quiet] sync [--recursive] [--] [<path>…​]git submodule [--quiet] absorbgitdirs [--] [<path>…​]

示例:

1.添加子模块

$ git submodule add http://github.com/chaconinc/DbConnectorCloning into 'DbConnector'...remote: Counting objects: 11, done.remote: Compressing objects: 100% (10/10), done.remote: Total 11 (delta 0), reused 11 (delta 0)Unpacking objects: 100% (11/11), done.Checking connectivity... done.

默认情况下,子模块会将子项目放到一个与仓库同名的目录中,本例中是 “DbConnector”。 如果你想要放到其他地方,那么可以在命令结尾添加一个不同的路径。

$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.Changes to be committed:  (use "git reset HEAD <file>..." to unstage)    new file:   .gitmodules    new file:   DbConnector

.gitmodules 文件。 该置文件保存了项目 URL 与已经拉取的本地目录之间的映射:

$ cat .gitmodules[submodule "DbConnector"]    path = DbConnector    url = http://github.com/chaconinc/DbConnector

2.克隆含有子模块的目录:

克隆一个含有子模块的项目,克隆这样的项目时,默认会包含该子模块目录,但其中还没有任何文件。

$ git clone http://github.com/chaconinc/MainProjectCloning into 'MainProject'...remote: Counting objects: 14, done.remote: Compressing objects: 100% (13/13), done.remote: Total 14 (delta 1), reused 13 (delta 0)Unpacking objects: 100% (14/14), done.Checking connectivity... done.$ cd MainProject$ ls -latotal 16drwxr-xr-x   9 schacon  staff  306 Sep 17 15:21 .drwxr-xr-x   7 schacon  staff  238 Sep 17 15:21 ..drwxr-xr-x  13 schacon  staff  442 Sep 17 15:21 .git-rw-r--r--   1 schacon  staff   92 Sep 17 15:21 .gitmodulesdrwxr-xr-x   2 schacon  staff   68 Sep 17 15:21 DbConnector-rw-r--r--   1 schacon  staff  756 Sep 17 15:21 Makefiledrwxr-xr-x   3 schacon  staff  102 Sep 17 15:21 includesdrwxr-xr-x   4 schacon  staff  136 Sep 17 15:21 scriptsdrwxr-xr-x   4 schacon  staff  136 Sep 17 15:21 src$ cd DbConnector/$ ls$

其中有 DbConnector 目录,不过是空的。 你必须运行两个命令:git submodule init 用来初始化本地配置文件,而 git submodule update 则从该项目中抓取所有数据并检出父项目中列出的合适的提交。

$ git submodule initSubmodule 'DbConnector' (http://github.com/chaconinc/DbConnector) registered for path 'DbConnector'$ git submodule updateCloning into 'DbConnector'...remote: Counting objects: 11, done.remote: Compressing objects: 100% (10/10), done.remote: Total 11 (delta 0), reused 11 (delta 0)Unpacking objects: 100% (11/11), done.Checking connectivity... done.Submodule path 'DbConnector': checked out 'c3f01dc8862123d317dd46284b05b6892c7b29bc'

不过还有更简单一点的方式。 如果给 git clone 命令传递 –recursive 选项,它就会自动初始化并更新仓库中的每一个子模块。

$ git clone --recursive http://github.com/chaconinc/MainProjectCloning into 'MainProject'...remote: Counting objects: 14, done.remote: Compressing objects: 100% (13/13), done.remote: Total 14 (delta 1), reused 13 (delta 0)Unpacking objects: 100% (14/14), done.Checking connectivity... done.Submodule 'DbConnector' (http://github.com/chaconinc/DbConnector) registered for path 'DbConnector'Cloning into 'DbConnector'...remote: Counting objects: 11, done.remote: Compressing objects: 100% (10/10), done.remote: Total 11 (delta 0), reused 11 (delta 0)Unpacking objects: 100% (11/11), done.Checking connectivity... done.Submodule path 'DbConnector': checked out 'c3f01dc8862123d317dd46284b05b6892c7b29bc'

2.下载安装Mingw64

Mingw64要从它的官网下载:http://mingw-w64.org/doku.php

这里写图片描述

打开下载的文件进行安装,但有一步非常重要,“architecture这一项要选择”x86_64”,

这里写图片描述

将mingw32-make.exe加入“路径变量“,打开文件夹:C:\Program Files\mingw-w64\x86_64-6.1.0-posix-seh-rt_v5-rev0\mingw64\bin,这就是刚才你安装Mingw64的地方,这里你会看到一个名为Mingw32-make.exe,待会要用到它,所以把它加入路径变量。

加好之后,打开的cmd,输入mingw32-make,如果输出如下,说明成功了

这里写图片描述

3.安装相关python包

4.安装xgboost

到​这一步应该所有准备工作都做好了,终于可以安装xgboost,打开“git bash”

​cd xgboost​alias make='mingw32-make'​cd dmlc-core​make -j4​cd ../rabit​make lib/librabit_empty.a -j4​cd ..​cp make/mingw64.mk config.mk​make -j4

alias命令:

alias 的基本使用方法为:

alias 新的命令=’原命令 -选项/参数’

例如:alias l=‘ls -lsh’将重新定义ls命令,现在只需输入l就可以列目录了。直接输入 alias 命令会列出当前系统中所有已经定义的命令别名。

要删除一个别名,可以使用 unalias 命令,如 unalias l。

make命令:

make 命令是系统管理员和程序员用的最频繁的命令之一。管理员用它通过命令行来编译和安装很多开源的工具,程序员用它来管理他们大型复杂的项目编译问题。

make命令像命令行参数一样接收目标。这些目标通常存放在以 “Makefile” 来命名的特殊文件中,同时文件也包含与目标相对应的操作。

make -j:用make -j带一个参数,可以把项目在进行并行编译,比如在一台双核的机器上,完全可以用make -j4,让make最多允许4个编译命令同时执行,这样可以更有效的利用CPU资源。

原创粉丝点击