# Use a Numpy Logistic Regression neural network to predict on dog and cat images

While there are machine learning and deep learning libraries, it is always a good idea to have an understanding of how the models are developed in order to enhance the student’s understanding of data science. In this blog post, therefore, I intend to discuss how to create a numpy logistic regression neural network in order to classify dog and cat images. In order to accomplish this task, I have used some of the code from grantgasser’s Github account. I would like to add, however, that the code required modifications before I could get it to work.

I have used Kaggle’s mini cats and dogs dataset on this project, and it can be obtained here:- https://www.kaggle.com/datasets/eduardoanog/minidogsandcats/data

Logistic regression is a binary classification method. It can be modelled as a function that can take in any number of inputs and constrain the output to be between 0 and 1. This means, we can think of Logistic Regression as a one-layer neural network.

I have obtained the code for a numpy logistic regression neural network and have used it to write a program in Kaggle’s neural network, storing it in my account for that data science company.

The first thing that I did was to import the libraries that I would need to execute the program, being:-

- Numpy to create numpy arrays and perform numerical computations,
- Random to generate random numbers,
- PIL to process images,
- Cv2 to process images,
- Glob to process files,
- Shutil to process files, and
- Matplotlib to visualise the images.

I used the os library to retrieve all of the files that are in the input directory for this dataset:-

I then visualised one of each cat and dog image:-