4.1 The goal of this section is to copy and paste changes to a machine learning program and run the code file. We will discuss how the program works in Chapter 5.
4.2 The first step is to download the data for the program. Download pima-indians-diabetes.csv from https://networkrepository.com/pima-indians-diabetes.php . Open the file and remove the tab, comma, and semicolon checkmarks. Click OK. You should see comma delimited data in the LibreOffice Calc sheet. Save pima-indians-diabetes.csv to your working directory. For me it is C:\User\steve\Documents\pima-indians-diabetes.csv.
Navigate using File Explorer to pima-indians-diabetes.csv. Hold down the shift key, and right click on the file. Select Copy as path. The path name for the file is now in the clipboard.
4.3 Open testworking.txt in Notepad. Highlight ‘pima-indians-diabetes.csv’ and paste the path name from your clipboard. The line will now read:
dataset = loadtxt('C:\User\steve\Documents\pima-indians-diabetes.csv', delimiter=',')
We must make one more change to the path name. We must add a backslash to the path.
dataset = loadtxt('C:\\User\steve\Documents\pima-indians-diabetes.csv', delimiter=',')
We have completed the changes to the testworking.txt file. Use Save as to save the file as “testfinal.py” Remember the quotes.
4.4 Using Anaconda Navigator go to the Anaconda prompt in the Windows start menu. Type conda activate env2 to bring up the the conda environment env2. This was discussed in Chapter 2. At the command line navigate to the directory containing Documents, and testfinal.py. Use the dir, chdir, and chdir -dot-dot to navigate the windows command line. Type python testfinal.py and press enter to run the program.
(env2) steve@steve:~$ python testfinal.py
Several hundreds of lines of code will be listed on your screen with a final statement of accuracy. Your machine learning learning program worked. If not, check your code carefully, especially the paths. Google any error messages.
4.5 To exit the env2 and and return the prompt to normal.
(env2) steve@steve:~$ conda deactivate
Output
steve@steve:~$
Table of Contents
Ch1-Installation
Ch2-Conda Navigator
Ch3-Notepad Editor
Ch4-Run a Program
Ch5-Program Explained