-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtarefa_6.py
26 lines (18 loc) · 852 Bytes
/
tarefa_6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Ola vamos criar
import pickle
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
from sklearn.model_selection import cross_validate
from sklearn.pipeline import Pipeline
from sklearn.svm import LinearSVC
from sklearn.metrics import classification_report
with open('itens.pkl', 'rb') as f_in:
items = pickle.load(f_in)
print(f"Carregamos um conjunto com {len(items)} itens")
X_total, y_total = zip(*items) # O restante vai ser usado para treino
classifier = LinearSVC(loss='hinge', penalty='l2', random_state=42, class_weight='balanced')
clf = Pipeline([('vectorizer', CountVectorizer(strip_accents='unicode', ngram_range=(1, 2))),
('transformer', TfidfTransformer()),
('classifier', classifier)])
# TODO usar um crossvalidate com k = 5
cv_results = cv_results
print(cv_results)