Skip to content

Commit

Permalink
Revert "formating"
Browse files Browse the repository at this point in the history
This reverts commit 5b8de4f.
  • Loading branch information
guolinke committed Jan 31, 2020
1 parent 5b8de4f commit 106c081
Show file tree
Hide file tree
Showing 91 changed files with 8,269 additions and 10,024 deletions.
48 changes: 16 additions & 32 deletions docs/Parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,38 +190,6 @@ Core Parameters
Learning Control Parameters
---------------------------

- ``force_col_wise`` :raw-html:`<a id="force_col_wise" title="Permalink to this parameter" href="#force_col_wise">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool

- set ``force_col_wise=true`` will force LightGBM to use col-wise histogram build

- Recommend ``force_col_wise=true`` when:

- the number of cloumns is large, or the total number of bin is large

- when ``num_threads`` is large, e.g. ``>20``

- want to use small ``feature_fraction``, e.g. ``0.5``, to speed-up

- want to reduce memory cost

- when both ``force_col_wise`` and ``force_col_wise`` are ``false``, LightGBM will firstly try them both, and uses the faster one

- ``force_row_wise`` :raw-html:`<a id="force_row_wise" title="Permalink to this parameter" href="#force_row_wise">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool

- set ``force_row_wise=true`` will force LightGBM to use row-wise histogram build

- Recommend ``force_row_wise=true`` when:

- the number of data is large, and the number of total bin is relatively small

- want to use small ``bagging``, or ``goss``, to speed-up

- when ``num_threads`` is relatively small, e.g. ``<=16``

- set ``force_row_wise=true`` will double the memory cost for Dataset object, if your memory is not enough, you can try ``force_col_wise=true``

- when both ``force_col_wise`` and ``force_col_wise`` are ``false``, LightGBM will firstly try them both, and uses the faster one.

- ``max_depth`` :raw-html:`<a id="max_depth" title="Permalink to this parameter" href="#max_depth">&#x1F517;&#xFE0E;</a>`, default = ``-1``, type = int

- limit the max depth for tree model. This is used to deal with over-fitting when ``#data`` is small. Tree still grows leaf-wise
Expand Down Expand Up @@ -591,6 +559,22 @@ IO Parameters

- **Note**: disabling this may cause the slow training speed for sparse datasets

- ``max_conflict_rate`` :raw-html:`<a id="max_conflict_rate" title="Permalink to this parameter" href="#max_conflict_rate">&#x1F517;&#xFE0E;</a>`, default = ``0.0``, type = double, constraints: ``0.0 <= max_conflict_rate < 1.0``

- max conflict rate for bundles in EFB

- set this to ``0.0`` to disallow the conflict and provide more accurate results

- set this to a larger value to achieve faster speed

- ``is_enable_sparse`` :raw-html:`<a id="is_enable_sparse" title="Permalink to this parameter" href="#is_enable_sparse">&#x1F517;&#xFE0E;</a>`, default = ``true``, type = bool, aliases: ``is_sparse``, ``enable_sparse``, ``sparse``

- used to enable/disable sparse optimization

- ``sparse_threshold`` :raw-html:`<a id="sparse_threshold" title="Permalink to this parameter" href="#sparse_threshold">&#x1F517;&#xFE0E;</a>`, default = ``0.8``, type = double, constraints: ``0.0 < sparse_threshold <= 1.0``

- the threshold of zero elements percentage for treating a feature as a sparse one

- ``use_missing`` :raw-html:`<a id="use_missing" title="Permalink to this parameter" href="#use_missing">&#x1F517;&#xFE0E;</a>`, default = ``true``, type = bool

- set this to ``false`` to disable the special handle of missing value
Expand Down
52 changes: 24 additions & 28 deletions include/LightGBM/R_object_helper.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*!
* Copyright (c) 2017 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for
* license information.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*
* \brief A simple wrapper for accessing data in R object.
*
* \note
* Due to license issue, we cannot include R's header file, so use this simple
* wrapper instead. However, if R changes the way it defines objects, this file
* will need to be updated as well.
* Due to license issue, we cannot include R's header file, so use this simple wrapper instead.
* However, if R changes the way it defines objects, this file will need to be updated as well.
*/
#ifndef R_OBJECT_HELPER_H_
#define R_OBJECT_HELPER_H_
Expand All @@ -20,6 +18,7 @@
// use .Internal(internalsID()) to uuid
#define R_INTERNALS_UUID "2fdf6c18-697a-4ba7-b8ef-11c0d92f1327"


#ifdef R_VER_ABOVE_35
#define NAMED_BITS 16
struct lgbm_sxpinfo {
Expand Down Expand Up @@ -98,8 +97,8 @@ struct lgbm_promsxp {

typedef struct LGBM_SER {
struct lgbm_sxpinfo sxpinfo;
struct LGBM_SER *attrib;
struct LGBM_SER *gengc_next_node, *gengc_prev_node;
struct LGBM_SER* attrib;
struct LGBM_SER* gengc_next_node, *gengc_prev_node;
union {
struct lgbm_primsxp primsxp;
struct lgbm_symsxp symsxp;
Expand All @@ -117,50 +116,47 @@ struct lgbm_vecsxp {

typedef struct VECTOR_SER {
struct lgbm_sxpinfo sxpinfo;
struct LGBM_SER *attrib;
struct LGBM_SER *gengc_next_node, *gengc_prev_node;
struct LGBM_SER* attrib;
struct LGBM_SER* gengc_next_node, *gengc_prev_node;
struct lgbm_vecsxp vecsxp;
} VECTOR_SER, *VECSE;

typedef union {
VECTOR_SER s;
double align;
} SEXPREC_ALIGN;
typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN;

#define DATAPTR(x) ((reinterpret_cast<SEXPREC_ALIGN *>(x)) + 1)
#define DATAPTR(x) ((reinterpret_cast<SEXPREC_ALIGN*>(x)) + 1)

#define R_CHAR_PTR(x) (reinterpret_cast<char *> DATAPTR(x))
#define R_CHAR_PTR(x) (reinterpret_cast<char*>DATAPTR(x))

#define R_INT_PTR(x) (reinterpret_cast<int *> DATAPTR(x))
#define R_INT_PTR(x) (reinterpret_cast<int*> DATAPTR(x))

#define R_INT64_PTR(x) (reinterpret_cast<int64_t *> DATAPTR(x))
#define R_INT64_PTR(x) (reinterpret_cast<int64_t*> DATAPTR(x))

#define R_REAL_PTR(x) (reinterpret_cast<double *> DATAPTR(x))
#define R_REAL_PTR(x) (reinterpret_cast<double*> DATAPTR(x))

#define R_AS_INT(x) (*(reinterpret_cast<int *> DATAPTR(x)))
#define R_AS_INT(x) (*(reinterpret_cast<int*> DATAPTR(x)))

#define R_AS_INT64(x) (*(reinterpret_cast<int64_t *> DATAPTR(x)))
#define R_AS_INT64(x) (*(reinterpret_cast<int64_t*> DATAPTR(x)))

#define R_IS_NULL(x) ((*reinterpret_cast<LGBM_SE>(x)).sxpinfo.type == 0)

// 64bit pointer
#if INTPTR_MAX == INT64_MAX

#define R_ADDR(x) (reinterpret_cast<int64_t *> DATAPTR(x))
#define R_ADDR(x) (reinterpret_cast<int64_t*> DATAPTR(x))

inline void R_SET_PTR(LGBM_SE x, void *ptr) {
inline void R_SET_PTR(LGBM_SE x, void* ptr) {
if (ptr == nullptr) {
R_ADDR(x)[0] = (int64_t)(NULL);
} else {
R_ADDR(x)[0] = (int64_t)(ptr);
}
}

inline void *R_GET_PTR(LGBM_SE x) {
inline void* R_GET_PTR(LGBM_SE x) {
if (R_IS_NULL(x)) {
return nullptr;
} else {
auto ret = reinterpret_cast<void *>(R_ADDR(x)[0]);
auto ret = reinterpret_cast<void*>(R_ADDR(x)[0]);
if (ret == NULL) {
ret = nullptr;
}
Expand All @@ -170,21 +166,21 @@ inline void *R_GET_PTR(LGBM_SE x) {

#else

#define R_ADDR(x) (reinterpret_cast<int32_t *> DATAPTR(x))
#define R_ADDR(x) (reinterpret_cast<int32_t*> DATAPTR(x))

inline void R_SET_PTR(LGBM_SE x, void *ptr) {
inline void R_SET_PTR(LGBM_SE x, void* ptr) {
if (ptr == nullptr) {
R_ADDR(x)[0] = (int32_t)(NULL);
} else {
R_ADDR(x)[0] = (int32_t)(ptr);
}
}

inline void *R_GET_PTR(LGBM_SE x) {
inline void* R_GET_PTR(LGBM_SE x) {
if (R_IS_NULL(x)) {
return nullptr;
} else {
auto ret = reinterpret_cast<void *>(R_ADDR(x)[0]);
auto ret = reinterpret_cast<void*>(R_ADDR(x)[0]);
if (ret == NULL) {
ret = nullptr;
}
Expand Down
21 changes: 10 additions & 11 deletions include/LightGBM/application.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*!
* Copyright (c) 2016 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for
* license information.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
#ifndef LIGHTGBM_APPLICATION_H_
#define LIGHTGBM_APPLICATION_H_
Expand All @@ -21,12 +20,12 @@ class ObjectiveFunction;
class Metric;

/*!
* \brief The main entrance of LightGBM. this application has two tasks:
* Train and Predict.
* Train task will train a new model
* Predict task will predict the scores of test data using existing
* model, and save the score to disk.
*/
* \brief The main entrance of LightGBM. this application has two tasks:
* Train and Predict.
* Train task will train a new model
* Predict task will predict the scores of test data using existing model,
* and save the score to disk.
*/
class Application {
public:
Application(int argc, char** argv);
Expand Down Expand Up @@ -75,9 +74,9 @@ class Application {
std::unique_ptr<ObjectiveFunction> objective_fun_;
};


inline void Application::Run() {
if (config_.task == TaskType::kPredict ||
config_.task == TaskType::KRefitTree) {
if (config_.task == TaskType::kPredict || config_.task == TaskType::KRefitTree) {
InitPredict();
Predict();
} else if (config_.task == TaskType::kConvertModel) {
Expand All @@ -90,4 +89,4 @@ inline void Application::Run() {

} // namespace LightGBM

#endif // LightGBM_APPLICATION_H_
#endif // LightGBM_APPLICATION_H_
Loading

0 comments on commit 106c081

Please sign in to comment.