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
df8c10ba
Unverified
Commit
df8c10ba
authored
Oct 05, 2021
by
James Lamb
Committed by
GitHub
Oct 06, 2021
Browse files
remove unused `DCGCalculator::CalDCGAtK()` (#4650)
parent
4b140bcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
32 deletions
+0
-32
include/LightGBM/metric.h
include/LightGBM/metric.h
+0
-11
src/metric/dcg_calculator.cpp
src/metric/dcg_calculator.cpp
+0
-21
No files found.
include/LightGBM/metric.h
View file @
df8c10ba
...
@@ -70,17 +70,6 @@ class DCGCalculator {
...
@@ -70,17 +70,6 @@ class DCGCalculator {
*/
*/
static
void
Init
(
const
std
::
vector
<
double
>&
label_gain
);
static
void
Init
(
const
std
::
vector
<
double
>&
label_gain
);
/*!
* \brief Calculate the DCG score at position k
* \param k The position to evaluate
* \param label Pointer of label
* \param score Pointer of score
* \param num_data Number of data
* \return The DCG score
*/
static
double
CalDCGAtK
(
data_size_t
k
,
const
label_t
*
label
,
const
double
*
score
,
data_size_t
num_data
);
/*!
/*!
* \brief Calculate the DCG score at multi position
* \brief Calculate the DCG score at multi position
* \param ks The positions to evaluate
* \param ks The positions to evaluate
...
...
src/metric/dcg_calculator.cpp
View file @
df8c10ba
...
@@ -106,27 +106,6 @@ void DCGCalculator::CalMaxDCG(const std::vector<data_size_t>& ks,
...
@@ -106,27 +106,6 @@ void DCGCalculator::CalMaxDCG(const std::vector<data_size_t>& ks,
}
}
}
}
double
DCGCalculator
::
CalDCGAtK
(
data_size_t
k
,
const
label_t
*
label
,
const
double
*
score
,
data_size_t
num_data
)
{
// get sorted indices by score
std
::
vector
<
data_size_t
>
sorted_idx
(
num_data
);
for
(
data_size_t
i
=
0
;
i
<
num_data
;
++
i
)
{
sorted_idx
[
i
]
=
i
;
}
std
::
stable_sort
(
sorted_idx
.
begin
(),
sorted_idx
.
end
(),
[
score
](
data_size_t
a
,
data_size_t
b
)
{
return
score
[
a
]
>
score
[
b
];
});
if
(
k
>
num_data
)
{
k
=
num_data
;
}
double
dcg
=
0.0
f
;
// calculate dcg
for
(
data_size_t
i
=
0
;
i
<
k
;
++
i
)
{
data_size_t
idx
=
sorted_idx
[
i
];
dcg
+=
label_gain_
[
static_cast
<
int
>
(
label
[
idx
])]
*
discount_
[
i
];
}
return
dcg
;
}
void
DCGCalculator
::
CalDCG
(
const
std
::
vector
<
data_size_t
>&
ks
,
const
label_t
*
label
,
void
DCGCalculator
::
CalDCG
(
const
std
::
vector
<
data_size_t
>&
ks
,
const
label_t
*
label
,
const
double
*
score
,
data_size_t
num_data
,
std
::
vector
<
double
>*
out
)
{
const
double
*
score
,
data_size_t
num_data
,
std
::
vector
<
double
>*
out
)
{
// get sorted indices by score
// get sorted indices by score
...
...
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