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
ade9bd51
Unverified
Commit
ade9bd51
authored
Jan 15, 2020
by
Guolin Ke
Committed by
GitHub
Jan 15, 2020
Browse files
update sampling solution (#2693)
parent
b161f334
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
include/LightGBM/utils/random.h
include/LightGBM/utils/random.h
+4
-4
No files found.
include/LightGBM/utils/random.h
View file @
ade9bd51
...
@@ -84,10 +84,10 @@ class Random {
...
@@ -84,10 +84,10 @@ class Random {
}
}
}
else
{
}
else
{
std
::
set
<
int
>
sample_set
;
std
::
set
<
int
>
sample_set
;
while
(
static_cast
<
int
>
(
sample_set
.
size
())
<
K
)
{
for
(
int
r
=
N
-
K
;
r
<
N
;
++
r
)
{
int
next
=
RandInt32
()
%
N
;
int
v
=
NextInt
(
0
,
r
)
;
if
(
sample_set
.
count
(
next
)
==
0
)
{
if
(
!
sample_set
.
insert
(
v
).
second
)
{
sample_set
.
insert
(
next
);
sample_set
.
insert
(
r
);
}
}
}
}
for
(
auto
iter
=
sample_set
.
begin
();
iter
!=
sample_set
.
end
();
++
iter
)
{
for
(
auto
iter
=
sample_set
.
begin
();
iter
!=
sample_set
.
end
();
++
iter
)
{
...
...
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