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
a3220a44
Commit
a3220a44
authored
Jun 25, 2012
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added comment to letter_recog.py sample (adopted from c++ version)
parent
5f6bbcc8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
letter_recog.py
samples/python2/letter_recog.py
+27
-4
No files found.
samples/python2/letter_recog.py
View file @
a3220a44
'''
The sample demonstrates how to train Random Trees classifier
(or Boosting classifier, or MLP, or Knearest, or Support Vector Machines) using the provided dataset.
We use the sample database letter-recognition.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.
The dataset consists of 20000 feature vectors along with the
responses - capital latin letters A..Z.
The first 10000 samples are used for training
and the remaining 10000 - to test the classifier.
======================================================
USAGE:
letter_recog.py [--model <model>]
[--data <data fn>]
[--load <model fn>] [--save <model fn>]
Models: RTrees, KNearest, Boost, SVM, MLP
'''
import
numpy
as
np
import
cv2
...
...
@@ -77,7 +102,6 @@ class Boost(LetterStatModel):
class
SVM
(
LetterStatModel
):
train_ratio
=
0.1
def
__init__
(
self
):
self
.
model
=
cv2
.
SVM
()
...
...
@@ -118,12 +142,11 @@ if __name__ == '__main__':
import
getopt
import
sys
print
__doc__
models
=
[
RTrees
,
KNearest
,
Boost
,
SVM
,
MLP
]
# NBayes
models
=
dict
(
[(
cls
.
__name__
.
lower
(),
cls
)
for
cls
in
models
]
)
print
'USAGE: letter_recog.py [--model <model>] [--data <data fn>] [--load <model fn>] [--save <model fn>]'
print
'Models: '
,
', '
.
join
(
models
)
print
args
,
dummy
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
''
,
[
'model='
,
'data='
,
'load='
,
'save='
])
args
=
dict
(
args
)
...
...
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