We will install Jupyter on a Windows

Operating System for a Python3, TensorFlow, and

Keras environment: Part II



AD

We assume you have completed Part I

for Anaconda and Anaconda-Navigator installation



In this series of tutorials we will download, and install Anaconda and Jupyter. We will configure Anaconda-Navigator for deep learning. This includes installation of Python3, TensorFlow, and Keras. We will test the installation with the Hello World of deep learning, the pima-indians-diabetes database.

We assume you have completed Part I on Anaconda installation.In this tutorial we will install and configure Jupyter, which comes as part of the Anaconda-Navigator installation. Jupyter is where you write the programs. Anaconda and Anaconda-Navigator will be present in your Start menu. Navigator will be configured for Deep Learning with Python3, Tensor-Flow, and Keras. We will start the tutorial by downloading the pima-indians-diabetes.csv database. We will use the database in the program I provide to test the Jupyter Notebook.



Download the pima-indians-diabetes.csv database to your computer.

1. This program is the Hello World program for testing deep learning programs. The pima-indians-diabetes database is used to predict whether or not a person will develop diabetes. The database consists of about a thousand lines. Each line contains eight values for traits related to diabetes for a person. The ninth value is a 0 or 1 for diabetes. We will explain in detail in the third segment of this tutorial.

2. Download the pima-indians-diabetes.csv dataset to your computer from https://networkrepository.com/pima-indians-diabetes.php . Just click the download button to save to Downloads on your computer. This works for Windows and Linux.

Click on Download button

Open Anaconda-Navigator and install Jupyter Notebook

3. Open Anaconda -> Anaconda-Navigator in the Start menu

Click on Download button

4. The Anaconda-Navigator Home page will open

Click on Download button

5. Select Environments. Select env1.

Select Environments. Select env1.

6. Select Home. Launch Jupyter Notebook.

From Home launch Jupyter Notebook.

7. After launching Jupyter Notebook, navigate to Start->Anaconda3->Jupyter Notebook (env1).

Navigate to Jupyter Notebook (env1)

8. Jupyter Notebook will open. (Remember that this is Jupyter Notebook with env1, that includes Python3, TensorFlow, and Keras.) Jupyter consists of two pages. A Home page, where we are now; and a code page.

9. From the Home page navigate to New->Notebook->Python3.

Home page.

10. The Jupyter code page will open, with an open line to place code.

Open a notebook code page.

A test program

11. At the beginning of the tutorial we downloaded the pima-indians-diabetes.csv database. We will now copy and paste the following code into the code window. Essentially the program determines the probability that a person will get diabetes given a set of initial conditions. For a more detailed analysis https://salarsen.com/AI/details-of-program-for-your-first-artificial-intelligence-program/index.html.

Note: I strongly suggest getting the PDF copy of Deep Learning With Python Develop Deep Learning Models on Theano and TensorFlow Using Keras by Jason Brownlee. It is thorough and easy to understand.

# first neural network with keras tutorial
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
# load the dataset
dataset = loadtxt("pima-indians-diabetes.csv", delimiter=',')
# split into input (X) and output (y) variables
# 0-8 are dependent variables- 8th column not included
X = dataset[:,0:8]
# 8 column is independent variable
y = dataset[:,8]
# define the keras model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# compile the keras model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# fit the keras model on the dataset
model.fit(X, y, epochs=150, batch_size=16)
# evaluate the keras model
# Use _, to get last item from iteration
_, accuracy = model.evaluate(X, y)
print('Accuracy: %.2f'% (accuracy*100))



12. Ater pasting the code from here to Jupyter Notebook, we must change the dataset path. We will copy and paste the path from the Downloads folder on your computer to the program on Jupyter.

Navigate to the Downloads folder and select pima-indians-diabetes.csv . Shift-Right Click on the file and select Copy as path. Go to your Jupyter code page. Highlight "pima-indians-diabetes.csv" and right click to paste the path into your code. The program line should now be similar to the following.(Instead of steve you will see your user name and your path.)

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 code.

Changes to code.

13. We will now run the code. Several hundreds of lines of output 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.

Changes to code.

Save your work

14. Save the work in the Notebook by clicking on the floppy disk icon in upper left of the toolbar. The Notebook file is also auto saved. Go to File > Close and Halt. You will return to the Home page. You can see the notebook name in a list of files and directories in the Home page. You can reopen a notebook by clicking on the file name.

Files saved on Home page.

15. You can change the name of the Notebook project at the top of the page by clicking on Untitled 0 and renaming the Notebook project.

16. The files are stored on your harddrive. The following is the location of my files. This PC > Windows(C:) > Users > Dottie > Untitled1.ipynb

Files saved on harddrive.

Congratulations! You ran your first program!

Follow the "Anaconda for Windows" navigation bar on the top left of the page. There are links to Part I, Anaconda Installation. There is also a link to a detailed analysis of the pima-indians-diabetes program. It was written for another tutorial on Colaboratory. There is also an introductory tutorial on basic Python used in the deep learning program.





theSurfDragon.com


Anaconda for Windows

SALARSEN.COM

Python Tutorial

Anaconda Installation I

Jupyter Installation II

Program Details