Skip to content

File not found Error in Naïve Bayes Project #361

@handyworkz

Description

@handyworkz

This is the code

import sys
from time import time
sys.path.append("C:/Users/ADWIN/Documents/GitHub/ud120-projects/tools")
from email_preprocess import preprocess


features_train, features_test, labels_train, labels_test = preprocess()


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
t0 =time()
clf.fit(features_train, labels_train)
print ("Training time: ", round(time()-t0, 3), "s")

t1 =time()
predictions = clf.predict(features_test)
print ("Prediction time: ", round(time()-t1, 3), "s")

from sklearn.metrics import accuracy_score
accuracy = accuracy_score(labels_test, predictions)
print(accuracy)

And this, the error

c:/Users/ADWIN/Documents/GitHub/ud120-projects/naive_bayes/nb_author_id.py Traceback (most recent call last): File "c:\Users\ADWIN\Documents\GitHub\ud120-projects\naive_bayes\nb_author_id.py", line 22, in <module> features_train, features_test, labels_train, labels_test = preprocess() File "C:\Users/ADWIN/Documents/GitHub/ud120-projects/tools\email_preprocess.py", line 30, in preprocess authors_file_handler = open(authors_file, "rb") FileNotFoundError: [Errno 2] No such file or directory: '../tools/email_authors.pkl'

Anytime I try to run the code, this error pops up, I have tried moving the email_preprocess file into the naive_bayes directory but the issue persists.

Can any one help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions