Alien-XGBoost

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "perl" : "5.008",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Test2::V0" : "0",
            "Test::Alien" : "0",
            "Test::Most" : "0",
            "utf8" : "0"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/pablrod/p5-Alien-XGBoost/issues"
      },
      "homepage" : "https://github.com/pablrod/p5-Alien-XGBoost",
      "repository" : {

META.yml  view on Meta::CPAN

  Alien::Build: '1.04'
  Alien::Build::MM: '0.32'
  ExtUtils::MakeMaker: '6.52'
  FFI::CheckLib: '0'
  FFI::Platypus: '0'
  Path::Tiny: '0'
  Sys::Info: '0'
  Test2::V0: '0'
  Test::Alien: '0'
  Test::Most: '0'
  utf8: '0'
configure_requires:
  Alien::Build: '0.32'
  Alien::Build::MM: '0.32'
  Alien::Build::Plugin::Build::CMake: '0.99'
  Alien::git: '0'
  ExtUtils::MakeMaker: '6.52'
  FFI::CheckLib: '0'
  FFI::Platypus: '0'
  Path::Tiny: '0'
  Sys::Info: '0'

Makefile.PL  view on Meta::CPAN

    "Alien::cmake3" => 0,
    "Alien::git" => 0,
    "base" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Test2::V0" => 0,
    "Test::Alien" => 0,
    "Test::Most" => 0,
    "utf8" => 0
  },
  "VERSION" => "0.05",
  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "Alien::Base" => 0,

Makefile.PL  view on Meta::CPAN

  "ExtUtils::MakeMaker" => "6.52",
  "FFI::CheckLib" => 0,
  "FFI::Platypus" => 0,
  "Path::Tiny" => 0,
  "Sys::Info" => 0,
  "Test2::V0" => 0,
  "Test::Alien" => 0,
  "Test::Most" => 0,
  "base" => 0,
  "strict" => 0,
  "utf8" => 0,
  "warnings" => 0
);


# BEGIN code inserted by Dist::Zilla::Plugin::AlienBuild
use Alien::Build::MM;
my $abmm = Alien::Build::MM->new;
%WriteMakefileArgs = $abmm->mm_args(%WriteMakefileArgs);
# END code inserted by Dist::Zilla::Plugin::AlienBuild

lib/Alien/XGBoost.pm  view on Meta::CPAN

our $VERSION = '0.05';    # VERSION

# ABSTRACT: Alien package to find, and build if necessary XGBoost dynamic library

1;

__END__

=pod

=encoding utf-8

=head1 NAME

Alien::XGBoost - Alien package to find, and build if necessary XGBoost dynamic library

=head1 VERSION

version 0.05

=head1 SYNOPSIS

t/10-dynamic_lib_xgboost.t  view on Meta::CPAN

#!/usr/bin/env perl -w

use strict;
use warnings;
use utf8;

use Test2::V0;
use Test::Alien;
use Alien::XGBoost;

alien_ok 'Alien::XGBoost';

# XGBoost C API lacks XGBVersion o similar
ffi_ok { symbols => [qw(XGBGetLastError XGDMatrixCreateFromMat)] }, with_subtest {
    my ($ffi) = @_;

t/20-xgboost_command.t  view on Meta::CPAN

#!/usr/bin/env perl -w

use strict;
use warnings;
use utf8;

use Test2::V0;
use Test::Alien;
use Alien::XGBoost;

alien_ok 'Alien::XGBoost';
run_ok('xgboost')->exit_is(0);

done_testing;

xgboost/R-package/vignettes/discoverYourData.Rmd  view on Meta::CPAN

title: "Understand your dataset with Xgboost"
output:
  rmarkdown::html_vignette:
    css: vignette.css
    number_sections: yes
    toc: yes
author: Tianqi Chen, Tong He, Michaël Benesty, Yuan Tang
vignette: >
  %\VignetteIndexEntry{Discover your data}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

Understand your dataset with XGBoost
====================================

Introduction
------------

The purpose of this vignette is to show you how to use **Xgboost** to discover and understand your own dataset better.

xgboost/R-package/vignettes/xgboostPresentation.Rmd  view on Meta::CPAN

output:
  rmarkdown::html_vignette:
    css: vignette.css
    number_sections: yes
    toc: yes
bibliography: xgboost.bib
author: Tianqi Chen, Tong He, Michaël Benesty
vignette: >
  %\VignetteIndexEntry{Xgboost presentation}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

XGBoost R Tutorial
==================

## Introduction


**Xgboost** is short for e**X**treme **G**radient **Boost**ing package.

xgboost/demo/kaggle-higgs/higgs-cv.py  view on Meta::CPAN

#!/usr/bin/python
import numpy as np
import xgboost as xgb

### load data in do training
train = np.loadtxt('./data/training.csv', delimiter=',', skiprows=1, converters={32: lambda x:int(x=='s'.encode('utf-8')) } )
label  = train[:,32]
data   = train[:,1:31]
weight = train[:,31]
dtrain = xgb.DMatrix( data, label=label, missing = -999.0, weight=weight )
param = {'max_depth':6, 'eta':0.1, 'silent':1, 'objective':'binary:logitraw', 'nthread':4}
num_round = 120

print ('running cross validation, with preprocessing function')
# define the preprocessing function
# used to return the preprocessed training, test data, and parameter

xgboost/demo/kaggle-higgs/higgs-numpy.py  view on Meta::CPAN

import numpy as np

import xgboost as xgb

test_size = 550000

# path to where the data lies
dpath = 'data'

# load in training data, directly use numpy
dtrain = np.loadtxt( dpath+'/training.csv', delimiter=',', skiprows=1, converters={32: lambda x:int(x=='s'.encode('utf-8')) } )
print ('finish loading from csv ')

label  = dtrain[:,32]
data   = dtrain[:,1:31]
# rescale weight to make it same as test set
weight = dtrain[:,31] * float(test_size) / len(label)

sum_wpos = sum( weight[i] for i in range(len(label)) if label[i] == 1.0  )
sum_wneg = sum( weight[i] for i in range(len(label)) if label[i] == 0.0  )

xgboost/demo/kaggle-higgs/higgs-pred.R  view on Meta::CPAN

# install xgboost package, see R-package in root folder
require(xgboost)
require(methods)

modelfile <- "higgs.model"
outfile <- "higgs.pred.csv"
dtest <- read.csv("data/test.csv", header=TRUE)
data <- as.matrix(dtest[2:31])
idx <- dtest[[1]]

xgmat <- xgb.DMatrix(data, missing = -999.0)
bst <- xgb.load(modelfile=modelfile)
ypred <- predict(bst, xgmat)

rorder <- rank(ypred, ties.method="first")

threshold <- 0.15
# to be completed
ntop <- length(rorder) - as.integer(threshold*length(rorder))
plabel <- ifelse(rorder > ntop, "s", "b")
outdata <- list("EventId" = idx,
                "RankOrder" = rorder,
                "Class" = plabel)
write.csv(outdata, file = outfile, quote=FALSE, row.names=FALSE)

xgboost/demo/kaggle-higgs/higgs-pred.py  view on Meta::CPAN

#!/usr/bin/python
# make prediction
import numpy as np
import xgboost as xgb

# path to where the data lies
dpath = 'data'

modelfile = 'higgs.model'
outfile = 'higgs.pred.csv'
# make top 15% as positive
threshold_ratio = 0.15

# load in training data, directly use numpy
dtest = np.loadtxt( dpath+'/test.csv', delimiter=',', skiprows=1 )
data   = dtest[:,1:31]
idx = dtest[:,0]

print ('finish loading from csv ')
xgmat = xgb.DMatrix( data, missing = -999.0 )

xgboost/demo/kaggle-higgs/higgs-pred.py  view on Meta::CPAN

ypred = bst.predict( xgmat )

res  = [ ( int(idx[i]), ypred[i] ) for i in range(len(ypred)) ]

rorder = {}
for k, v in sorted( res, key = lambda x:-x[1] ):
    rorder[ k ] = len(rorder) + 1

# write out predictions
ntop = int( threshold_ratio * len(rorder ) )
fo = open(outfile, 'w')
nhit = 0
ntot = 0
fo.write('EventId,RankOrder,Class\n')
for k, v in res:
    if rorder[k] <= ntop:
        lb = 's'
        nhit += 1
    else:
        lb = 'b'
    # change output rank order to follow Kaggle convention

xgboost/dmlc-core/doc/conf.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#

xgboost/dmlc-core/doc/conf.py  view on Meta::CPAN


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.md']

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

xgboost/dmlc-core/doc/sphinx_util.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
"""Helper utilty function for customization."""
import sys
import os
import docutils
import subprocess

if os.environ.get('READTHEDOCS', None) == 'True':
    subprocess.call('cd ..; rm -rf recommonmark;' +
                    'git clone https://github.com/tqchen/recommonmark', shell=True)

xgboost/dmlc-core/scripts/lint.py  view on Meta::CPAN

        _HELPER.pylint_opts = ['--rcfile='+args.pylint_rc,]
    file_type = args.filetype
    allow_type = []
    if file_type == 'python' or file_type == 'all':
        allow_type += [x for x in PYTHON_SUFFIX]
    if file_type == 'cpp' or file_type == 'all':
        allow_type += [x for x in CXX_SUFFIX]
    allow_type = set(allow_type)
    if sys.version_info.major == 2 and os.name != 'nt':
        sys.stderr = codecs.StreamReaderWriter(sys.stderr,
                                               codecs.getreader('utf8'),
                                               codecs.getwriter('utf8'),
                                               'replace')
    for path in args.path:
        if os.path.isfile(path):
            process(path, allow_type)
        else:
            for root, dirs, files in os.walk(path):
                for name in files:
                    process(os.path.join(root, name), allow_type)

    nerr = _HELPER.print_summary(sys.stderr)

xgboost/dmlc-core/windows/dmlc/dmlc.vcxproj  view on Meta::CPAN

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>

xgboost/doc/conf.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#

xgboost/doc/conf.py  view on Meta::CPAN


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.md']

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

xgboost/doc/sphinx_util.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
"""Helper utilty function for customization."""
import sys
import os
import docutils
import subprocess

READTHEDOCS_BUILD = (os.environ.get('READTHEDOCS', None) is not None)

if not os.path.exists('../recommonmark'):
    subprocess.call('cd ..; rm -rf recommonmark;' +

xgboost/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/rabit/util/RabitTrackerHelpers.scala  view on Meta::CPAN

    def asNativeOrderByteBuffer: ByteBuffer = {
      bs.asByteBuffer.order(ByteOrder.nativeOrder())
    }
  }

  implicit class ByteBufferHelpers(buf: ByteBuffer) {
    def getString: String = {
      val len = buf.getInt()
      val stringBuffer = ByteBuffer.allocate(len).order(ByteOrder.nativeOrder())
      buf.get(stringBuffer.array(), 0, len)
      new String(stringBuffer.array(), "utf-8")
    }
  }
}

xgboost/python-package/xgboost/__init__.py  view on Meta::CPAN

# coding: utf-8
"""XGBoost: eXtreme Gradient Boosting library.

Contributors: https://github.com/dmlc/xgboost/blob/master/CONTRIBUTORS.md
"""

from __future__ import absolute_import

import os

from .core import DMatrix, Booster

xgboost/python-package/xgboost/callback.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable= invalid-name
"""Training Library containing training routines."""
from __future__ import absolute_import

from . import rabit
from .core import EarlyStopException


def _get_callback_context(env):
    """return whether the current callback context is cv or train"""

xgboost/python-package/xgboost/compat.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable= invalid-name,  unused-import
"""For compatibility"""

from __future__ import absolute_import

import sys


PY3 = (sys.version_info[0] == 3)

if PY3:
    # pylint: disable=invalid-name, redefined-builtin
    STRING_TYPES = str,

    def py_str(x):
        """convert c string back to python string"""
        return x.decode('utf-8')
else:
    # pylint: disable=invalid-name
    STRING_TYPES = basestring,

    def py_str(x):
        """convert c string back to python string"""
        return x

try:
    import cPickle as pickle   # noqa

xgboost/python-package/xgboost/core.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable=too-many-arguments, too-many-branches, invalid-name
# pylint: disable=too-many-branches, too-many-lines, W0141
"""Core XGBoost Library."""
from __future__ import absolute_import

import sys
import os
import ctypes
import collections
import re

xgboost/python-package/xgboost/core.py  view on Meta::CPAN


    Parameters
    ----------
    data : list
        list of str
    """

    if isinstance(data, list):
        pointers = (ctypes.c_char_p * len(data))()
        if PY3:
            data = [bytes(d, 'utf-8') for d in data]
        else:
            data = [d.encode('utf-8') if isinstance(d, unicode) else d
                    for d in data]
        pointers[:] = data
        return pointers
    else:
        # copy from above when we actually use it
        raise NotImplementedError


def from_cstr_to_pystr(data, length):
    """Revert C pointer to Python str

xgboost/python-package/xgboost/core.py  view on Meta::CPAN

        pointer to data
    length : ctypes pointer
        pointer to length of data
    """
    if PY3:
        res = []
        for i in range(length.value):
            try:
                res.append(str(data[i].decode('ascii')))
            except UnicodeDecodeError:
                res.append(str(data[i].decode('utf-8')))
    else:
        res = []
        for i in range(length.value):
            try:
                res.append(str(data[i].decode('ascii')))
            except UnicodeDecodeError:
                res.append(unicode(data[i].decode('utf-8')))
    return res


def _load_lib():
    """Load xgboost Library."""
    lib_path = find_lib_path()
    if len(lib_path) == 0:
        return None
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
    lib.XGBGetLastError.restype = ctypes.c_char_p

xgboost/python-package/xgboost/core.py  view on Meta::CPAN

        raise RuntimeError('expected char pointer')
    res = bytearray(length)
    rptr = (ctypes.c_char * length).from_buffer(res)
    if not ctypes.memmove(rptr, cptr, length):
        raise RuntimeError('memmove failed')
    return res


def c_str(string):
    """Convert a python string to cstring."""
    return ctypes.c_char_p(string.encode('utf-8'))


def c_array(ctype, values):
    """Convert a python string to c array."""
    return (ctype * len(values))(*values)


PANDAS_DTYPE_MAPPER = {'int8': 'int', 'int16': 'int', 'int32': 'int', 'int64': 'int',
                       'uint8': 'int', 'uint16': 'int', 'uint32': 'int', 'uint64': 'int',
                       'float16': 'float', 'float32': 'float', 'float64': 'float',

xgboost/python-package/xgboost/libpath.py  view on Meta::CPAN

# coding: utf-8
"""Find the path to xgboost dynamic library files."""

import os
import platform
import sys


class XGBoostLibraryNotFound(Exception):
    """Error thrown by when xgboost is not found"""
    pass

xgboost/python-package/xgboost/plotting.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable=too-many-locals, too-many-arguments, invalid-name,
# pylint: disable=too-many-branches
"""Plotting Library."""
from __future__ import absolute_import

import re
from io import BytesIO
import numpy as np
from .core import Booster
from .sklearn import XGBModel

xgboost/python-package/xgboost/rabit.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable= invalid-name

"""Distributed XGBoost Rabit related API."""
from __future__ import absolute_import
import sys
import ctypes
import numpy as np

from .core import _LIB, c_str, STRING_TYPES
from .compat import pickle

xgboost/python-package/xgboost/sklearn.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable=too-many-arguments, too-many-locals, invalid-name, fixme, E0012, R0912
"""Scikit-Learn Wrapper interface for XGBoost."""
from __future__ import absolute_import

import numpy as np
import warnings
from .core import Booster, DMatrix, XGBoostError
from .training import train

# Do not use class names on scikit-learn directly.

xgboost/python-package/xgboost/training.py  view on Meta::CPAN

# coding: utf-8
# pylint: disable=too-many-locals, too-many-arguments, invalid-name
# pylint: disable=too-many-branches, too-many-statements
"""Training Library containing training routines."""
from __future__ import absolute_import

import warnings
import numpy as np
from .core import Booster, STRING_TYPES, XGBoostError, CallbackEnv, EarlyStopException
from .compat import (SKLEARN_INSTALLED, XGBStratifiedKFold)
from . import rabit

xgboost/rabit/doc/conf.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#

xgboost/rabit/doc/conf.py  view on Meta::CPAN


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.md']

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

xgboost/rabit/doc/sphinx_util.py  view on Meta::CPAN

# -*- coding: utf-8 -*-
"""Helper utilty function for customization."""
import sys
import os
import docutils
import subprocess

if os.environ.get('READTHEDOCS', None) == 'True':
    subprocess.call('cd ..; rm -rf recommonmark;' +
                    'git clone https://github.com/tqchen/recommonmark', shell=True)



( run in 0.401 second using v1.01-cache-2.11-cpan-4d50c553e7e )