Error exporting "logistic_regression" in naive Bayes classifier

0

In this code we try to make a naybe bayes classifier and show a graph with the results.

import numpy as np
import matplotlib.pyplot as plt 
from sklearn.naive_bayes import GaussianNB

from logistic_regression import plot_classifier

imput_file="archivo.txt"
x=[]
y=[]

with open(input_file,'r') as f:
    for line in f.readlines():
        data=[float() for x in line.split(',') ]
        x.append(data[:-1])
        y.append(data[-1])

x=np.array(x)        
y=np.array(y)

classier_gausiannb=GaussianNB()
classier_gausiannb.fit(x,y)
y_pred = classifier_gaussiannb.preddict(x)

accuracy=100.0*(y==y_pred).sum()/x.shape[0]
print("La precisión del clasificador es ", round(acuracy,2),'%')

plot_classifier(classifier_gausiannb,x,y)
plt.show()

The error it gives is the following:

  

ImportError: No module named> 'sklearn.logistic_regression'

    
asked by Diego 04.06.2018 в 21:41
source

1 answer

1

Make sure you have the file logistic_regresion of which you are going to import since what you are looking for is not defined in sklearn, here is an example of how they use it. link

    
answered by 06.06.2018 в 17:53