Commit 98fe7787 authored by Tags's avatar Tags

Change model from 'frequency matrix model' into 'Direct model'

Changed into accordance list binary string data -> string data
parent 7201edad
......@@ -119,7 +119,6 @@ class Classifier:
@property
def teg_accordance(self, persantage=20):
"""
Class method for computing % af tag accordance
:return: tuple of % af tag accordance
......@@ -129,7 +128,8 @@ class Classifier:
temp_matrix = self.tag_frequency_matrix[row]
rez_summ = temp_matrix[self.matrix_test_data.toarray ()[0] > 0].sum ()
if rez_summ > (persantage / 100):
vector_accordance.append ((int(self.tags[row][0]), int (rez_summ * 1000) / 10, self.tags[row][1].decode('ascii', 'ignore')))
vector_accordance.append (
(int (self.tags[row][0]), int (rez_summ * 1000) / 10, self.tags[row][1].decode ('ascii', 'ignore')))
vector_accordance.sort (key=lambda tup: tup[1], reverse=True)
return vector_accordance
......@@ -249,7 +249,7 @@ if __name__ == "__main__":
for (tag,) in tags:
tag = int (tag)
# print(tag)
print (str (tag) + " " + tags_classif.tags[tag-1][1].decode ('ascii', 'ignore'))
print (str (tag) + " " + tags_classif.tags[tag - 1][1].decode ('ascii', 'ignore'))
exit (0)
tags_classif.db.query ("SELECT title, description FROM wp_esi_news ORDER BY RAND() LIMIT 25")
......@@ -270,4 +270,4 @@ if __name__ == "__main__":
# if i > 10: break
# Graph presentation results
# tags_classif.graph_results()
tags_classif.graph_results ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment