eu estou no python 3 e ele esta dando erro
from sklearn.naive_bayes import MultinomialNB
from dados import ler_dados
X, Y = ler_dados()
IA = MultinomialNB()
IA.fit(X,Y)
previsao = IA.predict(X)
diferencas = previsao - Y
tc = [d for d in diferencas if d == 0]
tx = len(tc)
tl = len(X)
ac = 100.00*tx/tl
print(diferencas)
print(tx)
print(ac)
esse aqui permite a leitura dos dados
import csv
def ler_dados():
X = []
Y = []
arquivo = open('acesso.csv','r')
leitor = csv.reader(arquivo)
next(leitor)
for home, como_funciona, contato, comprou in leitor:
X.append([int(home), int(como_funciona), int(contato)])
Y.append([int(comprou)])
return X, Y
esse aqui são os dados
home,como_funciona,contato,comprou
1,1,0,0
1,1,0,0
1,1,0,0
1,1,0,0
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
1,1,0,1
1,0,1,1
0,0,1,0
0,0,1,0
0,0,1,0
0,0,1,0
0,0,1,0
0,1,0,0
0,0,1,0
0,1,0,0
0,0,1,0
0,1,0,0
0,0,1,0
0,1,0,0
1,0,1,1
1,1,1,1
1,1,1,1
1,0,1,1
0,1,0,0
0,0,1,0
0,1,0,0
1,0,1,1
0,0,1,0
1,0,1,1
1,0,1,1
1,0,1,1
1,0,1,1
0,0,1,0
1,1,0,0
1,0,1,1
0,1,0,0
0,0,1,0
0,1,0,0
1,0,1,1
0,0,1,0
0,0,1,0
1,0,1,1
1,0,1,1
1,1,0,0
1,1,0,0
1,1,0,0
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
0,0,1,0
1,0,1,1
0,1,0,0
0,0,1,0
0,1,0,0
1,0,1,1
0,1,1,1
0,0,1,0
1,0,1,1
1,0,1,1
1,1,0,0
1,1,0,0
0,0,1,0
0,0,1,0
0,0,1,0
0,0,1,0
0,1,0,0
0,0,1,0
0,1,0,0
0,0,1,0
1,1,0,1
0,0,1,0
0,0,1,0
0,0,1,0
1,0,1,1
1,0,1,1
1,1,0,0
1,1,0,0
0,0,1,0
0,0,1,0
1,0,1,1
1,0,1,1
1,1,0,0
1,1,0,0
0,0,1,0
0,0,1,0
1,1,1,1
0,0,1,0
0,1,0,0
0,0,0,0
eis o erro
C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py:752: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
y = column_or_1d(y, warn=True)
Traceback (most recent call last):
File "C:/Users/User/Documents/guto/programas/usuario.py", line 14, in <module>
tc = [d for d in diferencas if d == 0]
File "C:/Users/User/Documents/guto/programas/usuario.py", line 14, in <listcomp>
tc = [d for d in diferencas if d == 0]
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
descobri que o codigo do professor da o mesmo erro que o meu e é no meu pc como eu disse estou no python 3!