Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Carlos-Francisco Méndez-Cruz
/
lcg-bioinfoI-bionlp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Carlos-Francisco Méndez-Cruz
2018-09-28 04:58:01 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
616028860ac988cb523fb7abc09776cfd20fd382
61602886
1 parent
29540efe
Training, crossvalidation and testing dataset
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
14 deletions
clasificacion-automatica/binding-thrombin-dataset/imb-training-testing-binding-thrombin.py
clasificacion-automatica/binding-thrombin-dataset/imb-training-testing-binding-thrombin.py
View file @
6160288
...
...
@@ -191,39 +191,33 @@ if __name__ == "__main__":
print
(
" Number of testing class I: {}"
.
format
(
y_test
.
count
(
'I'
)))
print
(
" Shape of testing matrix: {}"
.
format
(
X_test
.
shape
))
jobs
=
-
1
paramGrid
=
[]
nIter
=
20
crossV
=
10
print
(
"Defining randomized grid search..."
)
if
args
.
classifier
==
'SVM'
:
# SVM
c
lassifier
=
SVC
(
args
.
kernel
)
elif
args
.
c
lassifier
==
'BernoulliNB'
:
myC
lassifier
=
SVC
(
args
.
kernel
)
elif
args
.
myC
lassifier
==
'BernoulliNB'
:
# BernoulliNB
c
lassifier
=
BernoulliNB
()
myC
lassifier
=
BernoulliNB
()
elif
args
.
classifier
==
'kNN'
:
# kNN
k_range
=
list
(
range
(
1
,
7
,
2
))
classifier
=
KNeighborsClassifier
()
myClassifier
=
KNeighborsClassifier
()
else
:
print
(
"Bad classifier"
)
exit
()
print
(
" Done!"
)
print
(
"Training..."
)
c
lassifier
.
fit
(
X_train
,
y_train
)
myC
lassifier
.
fit
(
X_train
,
y_train
)
print
(
" Done!"
)
y_pred
=
c
lassifier
.
predict
(
X_test
)
best_parameters
=
c
lassifier
.
best_estimator_
.
get_params
()
y_pred
=
myC
lassifier
.
predict
(
X_test
)
best_parameters
=
myC
lassifier
.
best_estimator_
.
get_params
()
print
(
" Done!"
)
print
(
"Saving report..."
)
with
open
(
os
.
path
.
join
(
args
.
outputReportPath
,
args
.
outputReportFile
),
mode
=
'w'
,
encoding
=
'utf8'
)
as
oFile
:
oFile
.
write
(
'********** EVALUATION REPORT **********
\n
'
)
oFile
.
write
(
'Reduction: {}
\n
'
.
format
(
args
.
reduction
))
oFile
.
write
(
'Classifier: {}
\n
'
.
format
(
args
.
c
lassifier
))
oFile
.
write
(
'Classifier: {}
\n
'
.
format
(
args
.
myC
lassifier
))
oFile
.
write
(
'Kernel: {}
\n
'
.
format
(
args
.
kernel
))
oFile
.
write
(
'Accuracy: {}
\n
'
.
format
(
accuracy_score
(
y_test
,
y_pred
)))
oFile
.
write
(
'Precision: {}
\n
'
.
format
(
precision_score
(
y_test
,
y_pred
,
average
=
'weighted'
)))
...
...
Please
register
or
login
to post a comment