Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

codigo n funciona

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

  File "C:/Users/User/Documents/guto/programas/usuario.py", line 14
    tc = [d for d in diferencas if d = 0]
                                     ^
SyntaxError: invalid syntax
1 resposta
solução!

Boa noite, Daniel. Acho que foi só um pequeno problema, depois do if basta colocar "==" ao invés de "=" como mostra o erro

tc = [d for d in diferencas if d == 0]