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
f08969ed
Commit
f08969ed
authored
Dec 03, 2010
by
Gary Bradski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slight bug fix, docs
parent
58ec89f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
mushroom.cpp
samples/c/mushroom.cpp
+21
-16
No files found.
samples/c/mushroom.cpp
View file @
f08969ed
...
...
@@ -2,19 +2,25 @@
#include "opencv2/ml/ml.hpp"
#include <stdio.h>
/*
The sample demonstrates how to build a decision tree for classifying mushrooms.
It uses the sample base agaricus-lepiota.data from UCI Repository, here is the link:
Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998).
UCI Repository of machine learning databases
[http://www.ics.uci.edu/~mlearn/MLRepository.html].
Irvine, CA: University of California, Department of Information and Computer Science.
*/
// loads the mushroom database, which is a text file, containing
// one training sample per row, all the input variables and the output variable are categorical,
// the values are encoded by characters.
void
help
()
{
printf
(
"
\n
This program demonstrated the use of OpenCV's decision tree function for learning and predicting data
\n
"
"Call:
\n
"
"./mushroom <path to agaricus-lepiota.data>
\n
"
);
printf
(
"
\n
"
"The sample demonstrates how to build a decision tree for classifying mushrooms.
\n
"
"It uses the sample base agaricus-lepiota.data from UCI Repository, here is the link:
\n
"
"
\n
"
"Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998).
\n
"
"UCI Repository of machine learning databases
\n
"
"[http://www.ics.uci.edu/~mlearn/MLRepository.html].
\n
"
"Irvine, CA: University of California, Department of Information and Computer Science.
\n
"
"
\n
"
"// loads the mushroom database, which is a text file, containing
\n
"
"// one training sample per row, all the input variables and the output variable are categorical,
\n
"
"// the values are encoded by characters.
\n\n
"
);
}
int
mushroom_read_database
(
const
char
*
filename
,
CvMat
**
data
,
CvMat
**
missing
,
CvMat
**
responses
)
{
const
int
M
=
1024
;
...
...
@@ -294,9 +300,8 @@ int main( int argc, char** argv )
if
(
!
mushroom_read_database
(
base_path
,
&
data
,
&
missing
,
&
responses
)
)
{
printf
(
"Unable to load the training database
\n
"
"Pass it as a parameter: dtree <path to agaricus-lepiota.data>
\n
"
);
return
0
;
printf
(
"
\n
Unable to load the training database
\n\n
"
);
help
();
return
-
1
;
}
...
...
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