Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
exa_news_classificator
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vasyl Bodnaruk
exa_news_classificator
Commits
7a5d8e24
Commit
7a5d8e24
authored
Aug 22, 2017
by
Tags
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Method Cross validation
parent
0e68f99e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
news_classify_tag.py
news_classify_tag.py
+13
-7
No files found.
news_classify_tag.py
View file @
7a5d8e24
import
sys
,
os
import
os
# from _mysql import OperationalError
from
pprint
import
pprint
#
from pprint import pprint
import
nltk
import
numpy
as
np
import
_mysql
...
...
@@ -10,8 +10,7 @@ import _mysql
# noinspection PyUnresolvedReferences
class
Classifier
:
def
__init__
(
self
,
corpus
=
None
,
host
=
'176.58.117.151'
,
\
user
=
'esi'
,
password
=
'esi12345'
,
db
=
'esi'
,
port
=
3306
):
def
__init__
(
self
,
corpus
=
None
,
host
=
'176.58.117.151'
,
user
=
'esi'
,
password
=
'esi12345'
,
db
=
'esi'
,
port
=
3306
):
try
:
# import nltk
import
operator
...
...
@@ -336,8 +335,15 @@ def cross_validation():
print
(
"
\n
#"
,
str
(
i
))
print
(
"
\n
News title: "
+
title
.
decode
(
'ascii'
,
'ignore'
))
print
(
"Model calculated Accordance :"
,
end
=
" "
)
print
(
set
(
rez_accordance
))
print
(
"User classified tags for news:"
,
set
(
tags_in_article
))
for
item_tag
in
tags_classif
.
tags
:
if
int
(
item_tag
[
0
])
in
rez_accordance
:
print
(
item_tag
[
0
],
item_tag
[
1
]
.
decode
(
'ascii'
,
'ignore'
),
end
=
'; '
)
print
(
"
\n
User classified tags for news: "
,
end
=
""
)
# print(set(rez_accordance))
for
item_tag
in
tags_classif
.
tags
:
if
int
(
item_tag
[
0
])
in
tags_in_article
:
print
(
item_tag
[
0
],
item_tag
[
1
]
.
decode
(
'ascii'
,
'ignore'
),
end
=
'; '
)
print
(
"
\n\n
The Model was tasted on "
,
len
(
news_results
),
" news. "
)
print
(
"The total result is:"
,
total_score
/
len
(
news_results
))
...
...
@@ -354,7 +360,7 @@ if __name__ == "__main__":
tags_classif
=
Classifier
(
host
=
'localhost'
,
port
=
8080
,
user
=
'root'
,
password
=
'password'
,
db
=
'news'
)
# the method is not implicated
tags_classif
.
teach_model
()
tags_classif
.
save
()
#
tags_classif.save()
# exit(0)
cross_validation
()
...
...
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