AITS Journal
Published in

AITS Journal

Mushroom Classification Using Deep Learning

Photo by Marianna Che on Dribbble

Introduction

Dataset

Importing the necessary libraries

Reading the CSV file of the dataset

Examining the Data

The shape of the dataset

Dataset shape: (8124, 23)

Unique occurrences of ‘class’ column

array(['p', 'e'], dtype=object)

Count of the unique occurrences of ‘class’ column

e    4208
p 3916
Name: class, dtype: int64

Now let’s visualize the count of edible and poisonous mushrooms using Seaborn :

Data Manipulation

Data Preparation

(1625, 117)

Now, let’s go ahead and build our Deep Learning model

Compiling the model

Model Summary

Now, let’s fit the model :

...
Epoch 10/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0548 - accuracy: 0.9835 - val_loss: 0.0163 - val_accuracy: 0.9963
Epoch 11/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0526 - accuracy: 0.9849 - val_loss: 0.0140 - val_accuracy: 0.9988
Epoch 12/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0417 - accuracy: 0.9888 - val_loss: 0.0116 - val_accuracy: 0.9994
Epoch 13/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0402 - accuracy: 0.9905 - val_loss: 0.0100 - val_accuracy: 0.9994
Epoch 14/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0370 - accuracy: 0.9908 - val_loss: 0.0083 - val_accuracy: 0.9994
Epoch 15/15
204/204 [==============================] - 0s 2ms/step - loss: 0.0304 - accuracy: 0.9928 - val_loss: 0.0069 - val_accuracy: 0.9994

Model Evaluation

51/51 [==============================] - 0s 951us/step - loss: 0.0069 - accuracy: 0.9994
Accuracy: 99.94
Loss: 0.69

Now, let’s visualize the model training:

Making predictions on some values :

array([[1, 0],
[1, 0],
[0, 1],
[0, 1],
[1, 0],
[1, 0],
[0, 1],
[0, 1],
[1, 0],
[0, 1]])

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store