Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
11ed2630
Commit
11ed2630
authored
Mar 17, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more docs and tests.
parent
62cd23ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
random_forest_regression.h
dlib/random_forest/random_forest_regression.h
+6
-2
random_forest_regression_abstract.h
dlib/random_forest/random_forest_regression_abstract.h
+0
-0
random_forest.cpp
dlib/test/random_forest.cpp
+15
-1
No files found.
dlib/random_forest/random_forest_regression.h
View file @
11ed2630
...
...
@@ -46,6 +46,7 @@ namespace dlib
std
::
vector
<
feature
>&
feats
)
const
{
DLIB_ASSERT
(
max_num_feats
()
!=
0
);
num
=
std
::
min
(
num
,
num_feats
);
feats
.
clear
();
...
...
@@ -66,6 +67,7 @@ namespace dlib
const
feature
&
f
)
const
{
DLIB_ASSERT
(
max_num_feats
()
!=
0
);
return
item
(
f
);
}
...
...
@@ -290,6 +292,7 @@ namespace dlib
size_t
num
)
{
DLIB_CASSERT
(
num
>
0
);
num_trees
=
num
;
}
...
...
@@ -297,6 +300,7 @@ namespace dlib
double
frac
)
{
DLIB_CASSERT
(
0
<
frac
&&
frac
<=
1
);
feature_subsampling_frac
=
frac
;
}
...
...
@@ -344,7 +348,7 @@ namespace dlib
trained_function_type
train
(
const
std
::
vector
<
sample_type
>&
x
,
const
std
::
vector
<
double
>&
y
,
std
::
vector
<
double
>&
oob_values
// predicted y, basically like LOO-CV
std
::
vector
<
double
>&
oob_values
)
const
{
return
do_train
(
x
,
y
,
oob_values
,
true
);
...
...
@@ -355,7 +359,7 @@ namespace dlib
trained_function_type
do_train
(
const
std
::
vector
<
sample_type
>&
x
,
const
std
::
vector
<
double
>&
y
,
std
::
vector
<
double
>&
oob_values
,
// predicted y, basically like LOO-CV
std
::
vector
<
double
>&
oob_values
,
bool
compute_oob_values
)
const
{
...
...
dlib/random_forest/random_forest_regression_abstract.h
View file @
11ed2630
This diff is collapsed.
Click to expand it.
dlib/test/random_forest.cpp
View file @
11ed2630
...
...
@@ -41,6 +41,8 @@ namespace
{
istringstream
sin
(
get_decoded_string
());
print_spinner
();
typedef
matrix
<
double
,
0
,
1
>
sample_type
;
std
::
vector
<
double
>
labels
;
std
::
vector
<
sample_type
>
samples
;
...
...
@@ -61,7 +63,7 @@ namespace
auto
result
=
test_regression_function
(
df
,
samples
,
labels
);
// train: 2.239 0.987173 0.970669 1.1399
dlog
<<
LINFO
<<
"train: "
<<
trans
(
result
)
;
dlog
<<
LINFO
<<
"train: "
<<
result
;
DLIB_TEST_MSG
(
result
(
0
)
<
2.3
,
result
(
0
));
running_stats
<
double
>
rs
;
...
...
@@ -69,6 +71,18 @@ namespace
rs
.
add
(
std
::
pow
(
oobs
[
i
]
-
labels
[
i
],
2.0
));
dlog
<<
LINFO
<<
"OOB MSE: "
<<
rs
.
mean
();
DLIB_TEST_MSG
(
rs
.
mean
()
<
10.2
,
rs
.
mean
());
print_spinner
();
stringstream
ss
;
serialize
(
df
,
ss
);
decltype
(
df
)
df2
;
deserialize
(
df2
,
ss
);
DLIB_TEST
(
df2
.
get_num_trees
()
==
1000
);
result
=
test_regression_function
(
df2
,
samples
,
labels
);
// train: 2.239 0.987173 0.970669 1.1399
dlog
<<
LINFO
<<
"serialized train results: "
<<
result
;
DLIB_TEST_MSG
(
result
(
0
)
<
2.3
,
result
(
0
));
}
}
a
;
...
...
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