I am getting an error that says list() takes one argument and I tried to fix the line sample=random.sample(list(zip(data.sentence,data["labels"]),test_cases))
but i was unsuccessful (where I tried to pass like list([]))
Here is the error log
TypeError Traceback (most recent call last)
<ipython-input-320-f89ff3d9d45e> in <module>()
----> 1 random_sample_testing(data,model,tfidf_vectorizer,5)
<ipython-input-319-d6cc87a3cea8> in random_sample_testing(data, model, tfidf_vectorizer, test_cases)
2 def random_sample_testing(data,model,tfidf_vectorizer,test_cases):
3 print (model)
----> 4 sample=random.sample(list(zip(data.sentence,data["labels"]),test_cases))
5 new_term_freq_matrix = tfidf_vectorizer.transform([i[0] for i in sample])
6 new_term_freq_matrix=new_term_freq_matrix.todense()
TypeError: list() takes at most 1 argument (2 given)
import random
def random_sample_testing(data,model,tfidf_vectorizer,test_cases):
print (model)
sample=random.sample(list(zip(data.sentence,data["labels"]),test_cases))
new_term_freq_matrix = tfidf_vectorizer.transform([i[0] for i in sample])
new_term_freq_matrix=new_term_freq_matrix.todense()
for i in zip(zip([i[0] for i in sample],[i[1] for i in sample]),model.predict(new_term_freq_matrix)):
print (i[0][0])
print ("Actual::\t",i[0][1],"\nPredicted::\t",i[1])
Aucun commentaire:
Enregistrer un commentaire