We will install Jupyter on a Linux

Operating System for a Python3, TensorFlow, and

Keras environment: Part III



AD

We assume you have completed Part I and Part II

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 and Part II 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-Navigator button will be present in your desktop. Navigator is 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 nineth value is 0 or 1 for diabetes. We will explain in detail in the Program Details.

2. Download the pima-indians-diabetes.csv dataset to your computer from https://networkrepository.com/pima-indians-diabetes.php . Just click the green download button to save to Downloads on your computer.

Click on Download button

Open Anaconda-Navigator and install Jupyter Notebook

3. Open the Anaconda-Navigator Home page with the desktop launcher.

Click on Download button

4. Select Environments. Select env1.

Select Environments. Select env1.

5. Select Home. Launch Jupyter Notebook.

From Home launch Jupyter Notebook.

6. We can open Jupyter Notebook any time from Navigator by going to Environments->env1->Open with Jupyter Notebook.

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

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

Home page.

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

Open a notebook code page.

10. We will test Jupyter to see if everything is working properly. Type import Keras, and click on Run. If everything is working properly, you will see a blank line. If errors codes appear, we have a problem. We can now continue with pima-indians-diabetes test program.

import Keras

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://thesurfdragon.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. After pasting the code from here to Jupyter Notebook, we must change the dataset path. The program lines should now be similar to the following.(Instead of steve you will see your user name and your path.)

dataset = loadtxt('/home/steve/Downloads/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, where your jupyter files end in .ipynb. /home/Untitled1.ipynb



Congratulations! You ran your first program!

Follow the "Anaconda for Linux Mint" navigation bar on the top left of the page. There are links to Part I, and Part II. There is also a link to a detailed analysis of the pima-indians-diabetes program. It was written for another tutorial on Colaboratory. See an introductory tutorial on basic Python used in the deep learning program at https://salarsen.com.

Continue with Linux Mint and a test program with prediction - Part IV





theSurfDragon.com


Anaconda for Linux Mint

SALARSEN.COM
Python Tutorial
Anaconda Linux Install I
Navigator Install II
Jupyter Install III
Program Details