Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
430e2f20
Commit
430e2f20
authored
Jan 04, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5916 from berak:NormalBayesClassifier_bulk_prediction
parents
fade4028
5afd0e21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
nbayes.cpp
modules/ml/src/nbayes.cpp
+1
-1
test_mltests.cpp
modules/ml/test/test_mltests.cpp
+44
-0
No files found.
modules/ml/src/nbayes.cpp
View file @
430e2f20
...
...
@@ -236,7 +236,7 @@ public:
if
(
results_prob
)
{
rptype
=
results_prob
->
type
();
rpstep
=
results_prob
->
isContinuous
()
?
1
:
results_prob
->
step
/
results_prob
->
elemSize
();
rpstep
=
results_prob
->
isContinuous
()
?
results_prob
->
cols
:
results_prob
->
step
/
results_prob
->
elemSize
();
}
// allocate memory and initializing headers for calculating
cv
::
AutoBuffer
<
double
>
_buffer
(
nvars
*
2
);
...
...
modules/ml/test/test_mltests.cpp
View file @
430e2f20
...
...
@@ -128,4 +128,48 @@ TEST(ML_Boost, regression) { CV_AMLTest test( CV_BOOST ); test.safe_run(); }
TEST
(
ML_RTrees
,
regression
)
{
CV_AMLTest
test
(
CV_RTREES
);
test
.
safe_run
();
}
TEST
(
DISABLED_ML_ERTrees
,
regression
)
{
CV_AMLTest
test
(
CV_ERTREES
);
test
.
safe_run
();
}
TEST
(
ML_NBAYES
,
regression_5911
)
{
int
N
=
12
;
Ptr
<
ml
::
NormalBayesClassifier
>
nb
=
cv
::
ml
::
NormalBayesClassifier
::
create
();
// data:
Mat_
<
float
>
X
(
N
,
4
);
X
<<
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
4
,
3
,
2
,
1
,
4
,
3
,
2
,
1
,
4
,
3
,
2
,
1
,
4
,
3
,
2
,
1
;
// labels:
Mat_
<
int
>
Y
(
N
,
1
);
Y
<<
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
;
nb
->
train
(
X
,
ml
::
ROW_SAMPLE
,
Y
);
// single prediction:
Mat
R1
,
P1
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
Mat
r
,
p
;
nb
->
predictProb
(
X
.
row
(
i
),
r
,
p
);
R1
.
push_back
(
r
);
P1
.
push_back
(
p
);
}
// bulk prediction (continuous memory):
Mat
R2
,
P2
;
nb
->
predictProb
(
X
,
R2
,
P2
);
EXPECT_EQ
(
sum
(
R1
==
R2
)[
0
],
255
*
R2
.
total
());
EXPECT_EQ
(
sum
(
P1
==
P2
)[
0
],
255
*
P2
.
total
());
// bulk prediction, with non-continuous memory storage
Mat
R3_
(
N
,
1
+
1
,
CV_32S
),
P3_
(
N
,
3
+
1
,
CV_32F
);
nb
->
predictProb
(
X
,
R3_
.
col
(
0
),
P3_
.
colRange
(
0
,
3
));
Mat
R3
=
R3_
.
col
(
0
).
clone
(),
P3
=
P3_
.
colRange
(
0
,
3
).
clone
();
EXPECT_EQ
(
sum
(
R1
==
R3
)[
0
],
255
*
R3
.
total
());
EXPECT_EQ
(
sum
(
P1
==
P3
)[
0
],
255
*
P3
.
total
());
}
/* End of file. */
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