Sometimes because of the system environment or path issues, we can't run the code directly. Therefore, I used Anaconda to install the virutal environment to run the code. Here are the procedures to run the code step by step.
Download Anaconda from the official website to install it based on the system requirements.
- (Windows): Anaconda Powershell Prompt
- (Mac): Terminal
- Check the python version:
python --version
- Here is the cheat sheet to create the virtual environment.
- My virtual environment (udacity):
conda create --name udacity
- Enter the vitural environemnt:
conda activate udacity
- Install Scikit-Learn using conda:
conda install scikit-learn
- Install other modules using
conda install ...
if it has 'ModuleNotFoundError'. - Download the ud120-projects from github
- Enter the directory of the project, such as
..\ud120-projects-master\naive_bayes
- Run the python code:
python nb_author_id.py
- It will show the results of in the terminal:
No. of Chris training emails : 7936 No. of Sara training emails : 7884
- Download Visual Studio Code
- Select the folder to edit the python code