Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
licenseplates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
licenseplates
Commits
92b7ce59
Commit
92b7ce59
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up test scripts.
parent
fd9ecb95
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/find_svm_params.py
+7
-10
7 additions, 10 deletions
src/find_svm_params.py
src/test_classifier.py
+4
-4
4 additions, 4 deletions
src/test_classifier.py
with
11 additions
and
14 deletions
src/find_svm_params.py
+
7
−
10
View file @
92b7ce59
...
...
@@ -2,10 +2,8 @@
from
cPickle
import
load
from
Classifier
import
Classifier
#C = [float(2 ** p) for p in xrange(-5, 16, 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
)]
C
=
[
float
(
2
**
p
)
for
p
in
xrange
(
-
5
,
16
,
2
)]
Y
=
[
float
(
2
**
p
)
for
p
in
xrange
(
-
15
,
4
,
2
)]
best_classifier
=
None
print
'
Loading learning 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
results
=
[]
maximum
=
(
0
,
0
,
0
)
best
=
(
0
,)
i
=
0
for
c
in
C
:
...
...
@@ -26,9 +24,8 @@ for c in C:
classifier
.
train
(
learning_set
)
result
=
classifier
.
test
(
test_set
)
if
result
>
maximum
[
2
]:
maximum
=
(
c
,
y
,
result
)
best_classifier
=
classifier
if
result
>
best
[
0
]:
best
=
(
result
,
c
,
y
,
classifier
)
results
.
append
(
result
)
i
+=
1
...
...
@@ -52,6 +49,6 @@ for c in C:
print
print
'
\n
max:
'
,
maximum
print
'
\n
Best result: %.3f%% for C = %f and gamma = %f
'
%
best
[:
3
]
best
_classifier
.
save
(
'
best_
classifier.dat
'
)
best
[
3
]
.
save
(
'
classifier.dat
'
)
This diff is collapsed.
Click to expand it.
src/test_classifier.py
+
4
−
4
View file @
92b7ce59
...
...
@@ -41,11 +41,11 @@ learning_set = load(file('learning_set.dat', 'r'))
# Train the classifier with the learning set
classifier
=
Classifier
(
c
=
512
,
gamma
=
.
125
,
cell_size
=
12
)
classifier
.
train
(
learning_set
)
#
classifier.save('classifier')
#
print 'Saved classifier'
classifier
.
save
(
'
classifier
.dat
'
)
print
'
Saved classifier
'
#----------------------------------------------------------------
#
print 'Loading classifier'
#
classifier = Classifier(filename='classifier')
print
'
Loading classifier
'
classifier
=
Classifier
(
filename
=
'
classifier
.dat
'
)
print
'
Loading test set
'
test_set
=
load
(
file
(
'
test_set.dat
'
,
'
r
'
))
l
=
len
(
test_set
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment