Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
licenseplates
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
licenseplates
Commits
92b7ce59
Commit
92b7ce59
authored
Dec 20, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up test scripts.
parent
fd9ecb95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
14 deletions
+11
-14
src/find_svm_params.py
src/find_svm_params.py
+7
-10
src/test_classifier.py
src/test_classifier.py
+4
-4
No files found.
src/find_svm_params.py
View file @
92b7ce59
...
@@ -2,10 +2,8 @@
...
@@ -2,10 +2,8 @@
from
cPickle
import
load
from
cPickle
import
load
from
Classifier
import
Classifier
from
Classifier
import
Classifier
#C = [float(2 ** p) for p in xrange(-5, 16, 2)]
C
=
[
float
(
2
**
p
)
for
p
in
xrange
(
-
5
,
16
,
2
)]
#Y = [float(2 ** p) for p in xrange(-15, 4, 2)]
Y
=
[
float
(
2
**
p
)
for
p
in
xrange
(
-
15
,
4
,
2
)]
C
=
[
float
(
2
**
p
)
for
p
in
xrange
(
1
,
16
,
2
)]
Y
=
[
float
(
2
**
p
)
for
p
in
xrange
(
-
13
,
4
,
2
)]
best_classifier
=
None
best_classifier
=
None
print
'Loading learning set...'
print
'Loading learning set...'
...
@@ -17,7 +15,7 @@ print 'Test set:', [c.value for c in test_set]
...
@@ -17,7 +15,7 @@ print 'Test set:', [c.value for c in test_set]
# Perform a grid-search on different combinations of soft margin and gamma
# Perform a grid-search on different combinations of soft margin and gamma
results
=
[]
results
=
[]
maximum
=
(
0
,
0
,
0
)
best
=
(
0
,
)
i
=
0
i
=
0
for
c
in
C
:
for
c
in
C
:
...
@@ -26,9 +24,8 @@ for c in C:
...
@@ -26,9 +24,8 @@ for c in C:
classifier
.
train
(
learning_set
)
classifier
.
train
(
learning_set
)
result
=
classifier
.
test
(
test_set
)
result
=
classifier
.
test
(
test_set
)
if
result
>
maximum
[
2
]:
if
result
>
best
[
0
]:
maximum
=
(
c
,
y
,
result
)
best
=
(
result
,
c
,
y
,
classifier
)
best_classifier
=
classifier
results
.
append
(
result
)
results
.
append
(
result
)
i
+=
1
i
+=
1
...
@@ -52,6 +49,6 @@ for c in C:
...
@@ -52,6 +49,6 @@ for c in C:
print
print
print '
\
n
max
:
', maximum
print '
\
n
Best
result
:
%
.
3
f
%%
for
C
=
%
f
and
gamma
=
%
f' % best[:3]
best
_classifier.save('
best_
classifier
.
dat
')
best
[3].save('
classifier
.
dat
')
src/test_classifier.py
View file @
92b7ce59
...
@@ -41,11 +41,11 @@ learning_set = load(file('learning_set.dat', 'r'))
...
@@ -41,11 +41,11 @@ learning_set = load(file('learning_set.dat', 'r'))
# Train the classifier with the learning set
# Train the classifier with the learning set
classifier
=
Classifier
(
c
=
512
,
gamma
=
.
125
,
cell_size
=
12
)
classifier
=
Classifier
(
c
=
512
,
gamma
=
.
125
,
cell_size
=
12
)
classifier
.
train
(
learning_set
)
classifier
.
train
(
learning_set
)
#classifier.save('classifier
')
classifier
.
save
(
'classifier.dat
'
)
#
print 'Saved classifier'
print
'Saved classifier'
#----------------------------------------------------------------
#----------------------------------------------------------------
#
print 'Loading classifier'
print
'Loading classifier'
#classifier = Classifier(filename='classifier
')
classifier
=
Classifier
(
filename
=
'classifier.dat
'
)
print
'Loading test set'
print
'Loading test set'
test_set
=
load
(
file
(
'test_set.dat'
,
'r'
))
test_set
=
load
(
file
(
'test_set.dat'
,
'r'
))
l
=
len
(
test_set
)
l
=
len
(
test_set
)
...
...
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