Page 1

To eat, or not to eat

CAN YOU TRUST MACHINES TO IDENTIFY POISONOUS MUSHROOMS? By Sophie Huang

©ISTOCK/ILEXX


MACHINES AND MUSHROOMS There is a saying in Italian, “compliments are like mushrooms, the most beautiful are the most poisonous.” Amusing as this quote may be, it tells a common bias on poisonous mushrooms – they have obvious physical characteristics for identification. In reality, many fatal mushrooms, such as deadly webcaps and destroying angels, look extremely plain and sometimes, very similar to edible mushrooms. In tradition, the only way to quickly identify poisonous wild mushrooms is through observation. Mushroom pickers learn from trial and errors by observing mushrooms and confirming their Young Destroying Angels (DEADLY) Young Inky Caps (EDIBLE) observations with field guides. In A Field (Source: Michael Guo) (Source: age FOTOSTOCK) Guide to Mushrooms: North America, Kent McKnight and Vera McKnight record detailed physical characteristics of wild mushrooms. The book classifies mushrooms into three categories: puffballs and relatives, gilled Trumpet Chanterelles (EDIBLE) Deadly Webcaps (DEADLY) (Source: www.mushroom.world) (Source: Association Mycologique de Bigorre) mushrooms, and non-gilled mushrooms. Colors of mushroom caps are also an important indicator of mushroom identities. According to another field guide, Field Guide to Common Macrofungi in Eastern Forests and Their Ecosystem Functions published by U.S. Department of Agriculture, mushroom pickers can first observe the ecosystems and living environment of the wild mushrooms to identify a range of potential mushroom species. For example, are the mushrooms growing

in Northern Hardwood Ecosystem or Aspen-Birch Ecosystem, on wood or ground? What type of trees are associated with the ecosystem?

" All fungi are edible. Some fungi are only edible once."

- TERRY PRATCHETT The traditional approaches to identify wild mushroom heavily depend on one’s observation, experience, and references to field guides.However, even very experienced and careful mushroom pickers make catastrophic mistakes, because mushrooms change their shapes and sizes during different growth stages and weather conditions. For instance, Nicolas Evans, the author of The Horse Whisperer, had to go through a kidney transplant to save his life after misidentifying and consuming deadly webcaps as edible ceps. During his recovery from mushroom poisoning, Nicolas Evans said in an interview, “a mushroom that comes out of the ground often looks quite sort of closed in on itself and then it can spread and become something that looks almost altogether different. So, you have to be sure of what you're eating and if you don't, you're like we were, foolish. . .”

As you can see, wild mushroom picking can be extremely dangerous. Every year, a few mushroom pickers succumbed. In the summer of 2018, I went to mushroom picking at the Central Park of New York City. What I learned at the end of the mushroom picking, is that in real life, it is difficult to identify the edibility of mushrooms with confidence. It is almost impossible to say, “it will be 100% safe to eat this mushroom.” The fear and confusions that come with identifying wild mushrooms led me to think of alternatives different than observations through human eyes. What if we let machines identify poisonous


mushrooms? In theory, an image recognition application can be used to identify and classify mushrooms. To build an effective image recognition application, one needs to implement artificial neural networks (ANN) in the application. Luckily, technology pioneers such as Google, Microsoft, and Amazon have developed and released their own ANN workstations and tutorials so that we can build mushroom classifiers with help from the technology giants. For example, Google Brain team released a public library named TensorFlow which contains various code base and tutorials that help people in all professions to get hands-on experience in building ANN. After diving into several articles published by Google Brain and Microsoft, I decided to build three simple mushroom classifiers to see if it is possible for a machine to make better decisions than we do on identifying poisonous mushrooms. In the following sections, I will discuss the building and testing results of the mushroom classifiers.

CLASSIFY MUSHROOMS, THE MACHINE WAY One has to have some ideas of how ANN works to understand the logic behinds a mushroom classifier. What is ANN? According to DeepAI, ANN is a computer framework inspired by biological neural networks within animal brains. You can visualize ANN as multiple layers of neurons, and the layers are connected in a way similar to synapses:

Source: Facundo Bre

When users feed in a picture of mushrooms, each pixel of the picture will be one neuron in the input layer. The first layer (input layer) then fires at the second layer. And the second layer fires at the third layer. The rest of the layers has the same mechanism. All layers together serve as a complex function that accepts pixels as inputs and returns probabilities as outputs. The picture below is an example of ANN trying to identify a picture of a cat.

Source: DeepAI

To better understand the potentials of ANN in distinguishing mushrooms, I designed three mushroom classifiers: 1. Mushroom classifier A classifies two mushroom species in pairs. For example, deadly webcaps and edible trumpet chanterelles is one pair; destroying angels and inky caps is one pair. This classifier can


only determine whether a mushroom belongs to either one of the two species.

Classifier B: Young Inky Caps (EDIBLE)

Trumpet Chanterelles (EDIBLE)

Destroying Angel (DEADLY)

Deadly Webcap (DEADLY)

2. Mushroom classifier B classifies all species from classifier A at once. Therefore, deadly webcaps, trumpet chanterelles, destroying angels and inky caps are all the possible outcomes. 3. Mushroom classifier C does not classify based on the species of mushrooms. Instead, it absorbs all kinds of mushroom pictures and divides the pictures into two large categories: edible and poisonous. The output of this classifier will only tell you the edibility of the mushrooms, and it will not tell you the name of the mushroom species. For each mushroom category or species, I feed in 1000-1200 pictures. After constructing the classifiers, I tested each classifier with 15 new images that were not fed into the ANN beforehand. Below are the representative results.

Classifier A: Young Inky Caps (EDIBLE) (Source: redforesta)

Destroying Angel (DEADLY) (Source: Alexey Sergeev)

Classifier C: Young Inky Caps (EDIBLE)

Destroying Angel (DEADLY)

Trumpet Chanterelles (EDIBLE)

Deadly Webcap (DEADLY)

Trumpet Chanterelles (EDIBLE) (Source: Unsavuliaat)

Deadly Webcap (DEADLY) (Source: Norwegian Institute of Public Health )

Interestingly, testing results show that mushroom classifier A did a wonderful job in classifying between two look-alike mushroom species. On a scale of 0 to 1, the certainty of classifier A is 0.99657 to 1. More importantly, classifier A is correct in classifying mushrooms every time based on the scores given by the classifier. Although classifier A is the most accurate, it has a downside: it can only identify mushrooms between two preset mushroom groups. That means mushroom pickers must be certain that the unidentified mushrooms are within either group.


When two classifier A’s with different mushroom pairs combine and create a classifier B, the certainty decreases. For example, the certainty of identifying the second image as trumpet chanterelle is 0.87421 according to classifier B. However, classifier A has 0.99943 certainty for the same image.

Classifier A

Classifier B

Trumpet Chanterelles (EDIBLE)

TO EAT, OR NOT TO EAT After comparing the accuracy of three mushroom classifiers, I presented classifier A to 23 people who do not have professional training in mushroom picking or identification. I showed them pictures of one species of poisonous mushrooms and one species of edible mushrooms (same pictures were being fed into the classifier A). Then, I let the people identify random mushroom images that I had not shown them.

As for classifier C, since mushrooms are divided into two broad categories – poisonous or edible, each category contains more than 20 mushroom species. The machine is confused by these two huge categories with many look-alike mushrooms. You can see from the test results of classifier C that one image of destroying angels was classified as edible with a score of 0.98203, which is entirely incorrect, because destroying angels are fatal.

Classifier C

Trumpet Chanterelles (EDIBLE)

Destroying Angel (DEADLY)

The consequences could be catastrophic if mushroom pickers follow the advice of classifier C.

Out of 184 guesses by users, 54 are wrong (29.35%), and 130 are right (70.65%). As for classifier A, the percentage of correct mushroom classification is 100%. This comparison shows that classifier A can effectively help mushroom pickers identify poisonous mushrooms. After users used mushroom classifier A, they were asked to rate their levels of confidence in letting computers classify mushrooms in the future. The ratings are based on the scale from 1 to 10. The graph on the right describes the outcome of the user survey.

6 13%

9 8.7%

7 13%

8 65.2%


As you can see from the user survey, the majority of people feels comfortable to use machines to identify mushrooms. I was surprised by such level of confidence. When I asked the users why they rated their confidence level at 8 or 9, they mentioned one very important thing: the speed. Indeed, the speed of classifier A to analyze one image is usually between 0.200 to 0.250 second, which is much faster than naked-eye observation. Such high speed can easily be used for image recognition for a large set of mushroom pictures. Imagine there are 100 unidentified mushroom images: since each mushroom image would take 0.2 - 0.25 second to identify, 100 mushroom images would only take classifier A 20-25 seconds to identify. The problem of classifier A is that it can only identify mushrooms between two species. Although users can customize the mushroom classifier by adding more species, the "scores" of certainty decrease. This is a technical problem that I have not been able to solve, but I believe that in the future, we will have a mushroom classifier that can classify more than dozens of mushrooms. There is another major concern about using machines to identify mushrooms: mushrooms change while machines do not change. Genetic mutations of a mushroom population can be a result of evolution. However, machines can only identify preset mushroom species. That means the machines cannot identify significant mutations. To give machines the ability to predict polymorphism in nature could be difficult, but not impossible. A few studies on using machine learning to predict polymorphism have Nature alone is been published. One of the studies is A comparative antique, and the oldest study of machine-learning methods to predict the effects of single nucleotide polymorphisms on protein art a mushroom. function, by Krishnan and Westhead. Although this study focuses on the polymorphisms of protein - Thomas Carlyle function, its mechanisms used for polymorphism prediction could be used for mushroom mutations.

In a nutshell, machines can identify and classify mushrooms efficiently, if you feed in the right information. It is worth noticing that although machines have great potentials in identifying objects in nature, they still need to "catch up" with nature constantly since nature tends to change things. Nature creates while the machines absorb what has been created. Classifying mushrooms will be an easy task for machines in the future, but with limitations. Is it possible to develop a mushroom classifier that classifies all mushrooms? Yes, when all mushrooms in the world are discovered. “Clothes I wear for mushroom hunting are rarely sent to the cleaner. They constitute a collection of odors I produce and gather while rambling in the woods. I notice not only dogs (cats, too) are delighted (they love to smell me).� - John Cage

________________________________________________ Explore more at TensorFlow Classifier https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0


REFERENCES 1. DeepAI. 2018. “Neural Network.” Neural Network. November 27. https://deepai.org/machine-learning-glossary-and-terms/neural-network 2. Evans, Nicholas. 2013. "Nicholas Evans: A poisonous mistake." The Naked Scientists. June 20. https://www.thenakedscientists.com/articles/interviews/nicholas-evanspoisonous-mistake 3. Glockner, Cyrill. 2017. "Deep Learning and Poisonous Mushrooms. " Towards Data Science. April 26. https://towardsdatascience.com/deep-learning-and-poisonous-mushrooms4377ea4c9b80. 4. Google Developers. 2018. "TensorFlow For Poets." TensorFlow. October 26. https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0. References 5. Hall, Ian Robert. 2003. Edible and Poisonous Mushrooms of the World. Portland: Timber Press. 6. Krishnan, V.G.; Westhead, D.R. 2003. "A comparative study of machinelearning methods to predict the effects of single nucleotide polymorphisms on protein function." Bioinformatics. Vol. 19: 2199-2209. 7. McKnight, Kent and Vera. 1998. A Field Guide to Mushrooms, North America. Boston: Houghton Mifflin.

8. Ostry, Michael; Anderson, Neil; O’Brien, Joseph. 2011. Field Guide to Common Macrofungi in Eastern Forests and Their Ecosystem Functions. Philadelphia: U.S. Department of Agriculture. 9. Simonyan, Karen; Zisserman, Andrew. 2015. “Very Deep Convolutional Networks for Large-scale Image Recognition.” The Computing Research Repository. 1409.1556: 1-14. 10. The Norwegian Poison Information Centre. 2018. “Poisonous mushrooms in Norway.” January 8. https://helsenorge.no/Giftinformasjon/Sopp/poisonous-mushrooms

To Eat, or Not to Eat: Can You Trust Machines to Identify Poisonous Mushrooms?  
To Eat, or Not to Eat: Can You Trust Machines to Identify Poisonous Mushrooms?  
Advertisement