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
6b73b4ae
Commit
6b73b4ae
authored
Jan 03, 2017
by
Guolin Ke
Browse files
Add LGBM_DatasetGetFeatureNames in c_api
parent
b7ed7395
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
include/LightGBM/c_api.h
include/LightGBM/c_api.h
+14
-0
src/c_api.cpp
src/c_api.cpp
+14
-0
No files found.
include/LightGBM/c_api.h
View file @
6b73b4ae
...
...
@@ -165,6 +165,20 @@ DllExport int LGBM_DatasetSetFeatureNames(
const
char
**
feature_names
,
int64_t
num_feature_names
);
/*!
* \brief get feature names of Dataset
* \param handle handle
* \param feature_names feature names, should pre-allocate memory
* \param num_feature_names number of feature names
* \return 0 when succeed, -1 when failure happens
*/
DllExport
int
LGBM_DatasetGetFeatureNames
(
DatasetHandle
handle
,
char
**
feature_names
,
int64_t
*
num_feature_names
);
/*!
* \brief free space for dataset
* \return 0 when succeed, -1 when failure happens
...
...
src/c_api.cpp
View file @
6b73b4ae
...
...
@@ -496,6 +496,20 @@ DllExport int LGBM_DatasetSetFeatureNames(
API_END
();
}
DllExport
int
LGBM_DatasetGetFeatureNames
(
DatasetHandle
handle
,
char
**
feature_names
,
int64_t
*
num_feature_names
)
{
API_BEGIN
();
auto
dataset
=
reinterpret_cast
<
Dataset
*>
(
handle
);
auto
inside_feature_name
=
dataset
->
feature_names
();
*
num_feature_names
=
static_cast
<
int64_t
>
(
inside_feature_name
.
size
());
for
(
int64_t
i
=
0
;
i
<
*
num_feature_names
;
++
i
)
{
std
::
strcpy
(
feature_names
[
i
],
inside_feature_name
[
i
].
c_str
());
}
API_END
();
}
DllExport
int
LGBM_DatasetFree
(
DatasetHandle
handle
)
{
API_BEGIN
();
delete
reinterpret_cast
<
Dataset
*>
(
handle
);
...
...
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