3.7 KiB
3.7 KiB
import pandas as pd
import csv
tsv_data = pd.read_csv('in.tsv', sep='\t',header=None, quoting=csv.QUOTE_NONE)[0]
expected = pd.read_csv('expected.tsv', sep='\t',header=None)[0]
print(len(expected))
print(len(tsv_data))
137314 137314
male={'silnik', 'windows', 'gb', 'mb', 'mecz', 'pc', 'opony', 'apple', 'iphone', 'zwiastuny', 'hd', 'ubuntu', 'system', 'serwer'}
female={'ciąża', 'miesiączki', 'ciasto', 'ciąże', 'zadowolona', 'antykoncepcyjne', 'ginekologia', 'tabletki', 'porodzie', 'mąż', 'krwawienie', 'ciasta'}
male = {x[:6].lower() for x in male}
female = {x[:6].lower() for x in female}
trimmed_docs=[]
for document in tsv_data:
new_doc=[]
for word in str(document).lower().split():
new_doc.append(word[:6])
trimmed_docs.append(new_doc)
male_or_female=[]
for doc in trimmed_docs:
male_or_female.append((len(male&set(doc)), len(female&set(doc))))
answers=[]
for i in male_or_female:
if i[0]>i[1]:
answers.append(1)
else:
answers.append(0)
result=[]
for i in range(len(answers)):
if answers[i]==expected[i]:
result.append(1)
else:
result.append(0)
print(f'Predykcja modelu wynosi {sum(result)/len(result)*100:.6f}%')
Predykcja modelu wynosi 51.007909%
df = pd.DataFrame(result)
df.to_csv('out.tsv', sep = '\t')