Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
64db9578
Commit
64db9578
authored
Dec 18, 2016
by
Guolin Ke
Browse files
fix #130
parent
db128c8d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
include/LightGBM/bin.h
include/LightGBM/bin.h
+11
-0
include/LightGBM/feature.h
include/LightGBM/feature.h
+3
-3
No files found.
include/LightGBM/bin.h
View file @
64db9578
...
@@ -113,6 +113,17 @@ public:
...
@@ -113,6 +113,17 @@ public:
*/
*/
inline
unsigned
int
ValueToBin
(
double
value
)
const
;
inline
unsigned
int
ValueToBin
(
double
value
)
const
;
/*!
* \brief Get the default bin when value is 0 or is firt categorical
* \return default bin
*/
inline
uint32_t
GetDefaultBin
()
const
{
if
(
bin_type_
==
BinType
::
NumericalBin
)
{
return
ValueToBin
(
0
);
}
else
{
return
0
;
}
}
/*!
/*!
* \brief Construct feature value to bin mapper according feature values
* \brief Construct feature value to bin mapper according feature values
* \param values (Sampled) values of this feature
* \param values (Sampled) values of this feature
...
...
include/LightGBM/feature.h
View file @
64db9578
...
@@ -27,7 +27,7 @@ public:
...
@@ -27,7 +27,7 @@ public:
:
bin_mapper_
(
bin_mapper
)
{
:
bin_mapper_
(
bin_mapper
)
{
feature_index_
=
feature_idx
;
feature_index_
=
feature_idx
;
bin_data_
.
reset
(
Bin
::
CreateBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_data_
.
reset
(
Bin
::
CreateBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_mapper_
->
sparse_rate
(),
is_enable_sparse
,
&
is_sparse_
,
bin_mapper_
->
ValueTo
Bin
(
0
),
bin_mapper_
->
bin_type
()));
bin_mapper_
->
sparse_rate
(),
is_enable_sparse
,
&
is_sparse_
,
bin_mapper_
->
GetDefault
Bin
(),
bin_mapper_
->
bin_type
()));
}
}
/*!
/*!
* \brief Constructor from memory
* \brief Constructor from memory
...
@@ -52,9 +52,9 @@ public:
...
@@ -52,9 +52,9 @@ public:
num_data
=
static_cast
<
data_size_t
>
(
local_used_indices
.
size
());
num_data
=
static_cast
<
data_size_t
>
(
local_used_indices
.
size
());
}
}
if
(
is_sparse_
)
{
if
(
is_sparse_
)
{
bin_data_
.
reset
(
Bin
::
CreateSparseBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_mapper_
->
ValueTo
Bin
(
0
),
bin_mapper_
->
bin_type
()));
bin_data_
.
reset
(
Bin
::
CreateSparseBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_mapper_
->
GetDefault
Bin
(),
bin_mapper_
->
bin_type
()));
}
else
{
}
else
{
bin_data_
.
reset
(
Bin
::
CreateDenseBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_mapper_
->
ValueTo
Bin
(
0
),
bin_mapper_
->
bin_type
()));
bin_data_
.
reset
(
Bin
::
CreateDenseBin
(
num_data
,
bin_mapper_
->
num_bin
(),
bin_mapper_
->
GetDefault
Bin
(),
bin_mapper_
->
bin_type
()));
}
}
// get bin data
// get bin data
bin_data_
->
LoadFromMemory
(
memory_ptr
,
local_used_indices
);
bin_data_
->
LoadFromMemory
(
memory_ptr
,
local_used_indices
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment