/**
* Copyright 2015~2023 by XGBoost Contributors
* \file c_api.h
* \author Tianqi Chen
* \brief C API of XGBoost, used for interfacing to other languages.
*/
#ifndef XGBOOST_C_API_H_
#define XGBOOST_C_API_H_
#ifdef __cplusplus
#define XGB_EXTERN_C extern "C"
#include <cstddef>
#include <cstdio>
#include <cstdint>
#else
#define XGB_EXTERN_C
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#endif // __cplusplus
#if defined(_MSC_VER) || defined(_WIN32)
#define XGB_DLL XGB_EXTERN_C __declspec(dllexport)
#else
#define XGB_DLL XGB_EXTERN_C __attribute__ ((visibility ("default")))
#endif // defined(_MSC_VER) || defined(_WIN32)
// manually define unsigned long
typedef uint64_t bst_ulong; // NOLINT(*)
/**
* @mainpage
*
* \brief XGBoost C API reference.
*
* For the official document page see:
* <a href="https://xgboost.readthedocs.io/en/stable/c.html">XGBoost C Package</a>.
*/
/**
* @defgroup Library
*
* These functions are used to obtain general information about XGBoost including version,
* build info and current global configuration.
*
* @{
*/
/*! \brief handle to DMatrix */
typedef void *DMatrixHandle; // NOLINT(*)
/*! \brief handle to Booster */
typedef void *BoosterHandle; // NOLINT(*)
/*!
* \brief Return the version of the XGBoost library being currently used.
*
* The output variable is only written if it's not NULL.
*
* \param major Store the major version number
* \param minor Store the minor version number
* \param patch Store the patch (revision) number
*/
XGB_DLL void XGBoostVersion(int* major, int* minor, int* patch);
/*!
* \brief Get compile information of shared library.
*
* \param out string encoded JSON object containing build flags and dependency version.
*
* \return 0 for success, -1 for failure
*/
XGB_DLL int XGBuildInfo(char const **out);
/*!
* \brief get string message of the last error
*
* all function in this file will return 0 when success
* and -1 when an error occurred,
* XGBGetLastError can be called to retrieve the error
*
* this function is thread safe and can be called by different thread
* \return const char* error information
*/
XGB_DLL const char *XGBGetLastError();
/*!
* \brief register callback function for LOG(INFO) messages -- helpful messages
* that are not errors.
* Note: this function can be called by multiple threads. The callback function
* will run on the thread that registered it
* \return 0 for success, -1 for failure
*/
XGB_DLL int XGBRegisterLogCallback(void (*callback)(const char*));
/*!
* \brief Set global configuration (collection of parameters that apply globally). This function
* accepts the list of key-value pairs representing the global-scope parameters to be
* configured. The list of key-value pairs are passed in as a JSON string.
* \param config a JSON string representing the list of key-value pairs. The JSON object shall
* be flat: no value can be a JSON object or an array.
* \return 0 for success, -1 for failure
*/
XGB_DLL int XGBSetGlobalConfig(char const *config);
/*!
* \brief Get current global configuration (collection of parameters that apply globally).
* \param out_config pointer to received returned global configuration, represented as a JSON string.
* \return 0 for success, -1 for failure
*/
XGB_DLL int XGBGetGlobalConfig(char const **out_config);
/**@}*/
/**
* @defgroup DMatrix
*
* @brief DMatrix is the baisc data storage for XGBoost used by all XGBoost algorithms
* including both training, prediction and explanation. There are a few variants of
* `DMatrix` including normal `DMatrix`, which is a CSR matrix, `QuantileDMatrix`,
* which is used by histogram-based tree methods for saving memory, and lastly the
* experimental external-memory-based DMatrix, which reads data in batches during
* training. For the last two variants, see the @ref Streaming group.
*
* @{
*/
/*!
* \brief load a data matrix
* \deprecated since 2.0.0
* \see XGDMatrixCreateFromURI()
* \param fname the name of the file
* \param silent whether print messages during loading
* \param out a loaded data matrix
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromFile(const char *fname, int silent, DMatrixHandle *out);
/*!
* \brief load a data matrix
* \param config JSON encoded parameters for DMatrix construction. Accepted fields are:
* - uri: The URI of the input file.
* - silent (optional): Whether to print message during loading. Default to true.
* - data_split_mode (optional): Whether to split by row or column. In distributed mode, the
* file is split accordingly; otherwise this is only an indicator on how the file was split
* beforehand. Default to row.
* \param out a loaded data matrix
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromURI(char const *config, DMatrixHandle *out);
/*!
* \brief create a matrix content from CSR format
* \deprecated since 2.0.0
* \see XGDMatrixCreateFromCSR()
*/
XGB_DLL int XGDMatrixCreateFromCSREx(const size_t *indptr, const unsigned *indices,
const float *data, size_t nindptr, size_t nelem,
size_t num_col, DMatrixHandle *out);
/**
* @example c-api-demo.c
*/
/*!
* \brief Create a matrix from CSR matrix.
* \param indptr JSON encoded __array_interface__ to row pointers in CSR.
* \param indices JSON encoded __array_interface__ to column indices in CSR.
* \param data JSON encoded __array_interface__ to values in CSR.
* \param ncol Number of columns.
* \param config JSON encoded configuration. Required values are:
* - missing: Which value to represent missing value.
* - nthread (optional): Number of threads used for initializing DMatrix.
* \param out created dmatrix
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
bst_ulong ncol, char const *config, DMatrixHandle *out);
/*!
* \brief Create a matrix from dense array.
* \param data JSON encoded __array_interface__ to array values.
* \param config JSON encoded configuration. Required values are:
* - missing: Which value to represent missing value.
* - nthread (optional): Number of threads used for initializing DMatrix.
* \param out created dmatrix
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
/*!
* \brief Create a matrix from a CSC matrix.
* \param indptr JSON encoded __array_interface__ to column pointers in CSC.
* \param indices JSON encoded __array_interface__ to row indices in CSC.
* \param data JSON encoded __array_interface__ to values in CSC.
* \param nrow number of rows in the matrix.
* \param config JSON encoded configuration. Supported values are:
* - missing: Which value to represent missing value.
* - nthread (optional): Number of threads used for initializing DMatrix.
* \param out created dmatrix
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
bst_ulong nrow, char const *c_json_config, DMatrixHandle *out);
/*!
* \brief create a matrix content from CSC format
* \deprecated since 2.0.0
* \see XGDMatrixCreateFromCSC()
*/
XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t *col_ptr, const unsigned *indices,
const float *data, size_t nindptr, size_t nelem,
size_t num_row, DMatrixHandle *out);
/*!
* \brief create matrix content from dense matrix
* \param data pointer to the data space
* \param nrow number of rows
* \param ncol number columns
* \param missing which value to repr
matlab xgboost安装调试
需积分: 0 131 浏览量
更新于2023-02-12
6
收藏 3.45MB RAR 举报
标题“matlab xgboost安装调试”涉及到的是在MATLAB环境中安装和配置XGBoost库的过程,以及可能遇到的问题和调试方法。XGBoost是一种高效、灵活且可扩展的梯度提升框架,常用于机器学习任务,特别是分类和回归问题。MATLAB作为流行的数值计算环境,提供了与各种外部库(如XGBoost)集成的能力,使得用户能够利用其强大的算法库进行建模和数据分析。
安装XGBoost通常包括以下步骤:
1. **下载XGBoost源码**:访问XGBoost官方GitHub仓库(https://github.com/dmlc/xgboost),下载最新版本的源代码。
2. **编译XGBoost**:解压下载的源代码,使用C++编译器(如GCC或Clang)进行编译,确保编译时添加对MATLAB的支持。这通常需要设置`-DUSE_MEX=ON`标志。
3. **生成MATLAB接口**:编译完成后,使用提供的`matlab/makefile`文件生成MATLAB接口。运行`make mex`命令,这将创建`xgboost.mexw64`(或对应于你的系统的文件)。
4. **设置MATLAB路径**:将生成的`xgboost.mexw64`文件移动到MATLAB的可寻址路径下,或者将其路径添加到MATLAB的路径列表中,以便在MATLAB中调用。
描述中的“调试不好联系我,刚注册账号不清楚”可能意味着用户在安装或使用过程中遇到了问题,可能包括编译错误、MATLAB找不到XGBoost库、运行时错误等。为了解决这些问题,建议用户:
1. **检查依赖**:确保系统已安装所有必要的依赖项,如C++编译器、OpenMP(如果需要并行计算)、以及MATLAB的开发工具箱。
2. **查看编译日志**:编译时的错误信息通常是解决问题的关键,仔细阅读并理解这些信息能帮助定位问题所在。
3. **查阅文档**:XGBoost的官方文档和MATLAB社区论坛通常有丰富的资源和解决方案。
4. **调试MATLAB代码**:如果在MATLAB中调用XGBoost出现问题,可以使用MATLAB的调试工具,设置断点,检查变量状态,以找出问题原因。
至于标签“xgboost matlab”,表明内容专注于这两个主题的结合。在MATLAB中使用XGBoost,用户可以利用其内置的优化和数据处理功能,创建模型并进行训练。XGBoost提供了多种优化参数,如学习率、树的数量、叶子节点的最大数量等,通过调整这些参数可以优化模型性能。
在文件列表中提到的“lib”,通常是指编译后的库文件,可能是XGBoost编译生成的一部分。在MATLAB中,`lib`目录下的文件可能包含了与XGBoost交互所需的动态链接库,这些文件对于正确运行MATLAB接口是至关重要的。
安装和调试MATLAB的XGBoost涉及到多个步骤,包括编译源码、生成MATLAB接口、设置环境路径以及解决可能出现的运行时问题。熟悉这些步骤并掌握调试技巧,对于高效地在MATLAB中利用XGBoost进行机器学习项目至关重要。
afdwangzhe123456
- 粉丝: 0
- 资源: 2
最新资源
- 全自动烤箱设备工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- 热熔胶涂布机工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- 熔喷布驻极流水线工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- 基于ruoyi-vue 3.8.8的BaiZe-ui设计源码,融合官方插件与文档便利店
- 基于C++与跨语言集成的AC学习笔记源码设计
- 基于Java和Vue的启航电商ERP系统2.0版设计源码
- 新年主题的概要介绍与分析
- python的概要介绍与分析
- 基于微信小程序的TT水果商城JavaScript开发设计源码
- 基于Java与多种前端技术的尚上优选社区团购微服务毕设项目设计源码
- 基于PHP开发的API访问控制与数据分析管理系统设计源码
- 基于RabbitMQ的分布式消息分发应用框架设计源码
- c语言的概要介绍与分析
- 快速排序的概要介绍与分析
- 基于Flutter的支付宝支付SDK插件Tobias设计源码
- 基于微信小程序的景区小程序设计源码