CSC207 - Lab 6
Edible Mushroom Detector

Overview

Last lab we studied the "life" portion of the search for intelligent life in the universe. This lab we investigate some pieces of "intelligence," using our ability to divide objects into categories.

Materials

Description

While the formal system of Boolean logic was developed by George Boole, the study of logic has roots as far back as Ancient Greece and Aristotle and his foundational work on Syllogisms. Our ability to reason logically and rationally is often cited as a primary indicator of our intelligence, not only on an individual level as measured by SAT and IQ tests, but also on a species level to distinguish our actions and behaviors from other organisms. As we search for life in the universe, we ultimately hope to find intelligent life elsewhere capable of communication; today we will spend our first lab understanding the basics of intelligence.

Artificial Intelligence (AI) is a field within computer science with the goal of recreating, through the user of a computer, the intelligence we see in human behavior. The goal of AI has yet to be achieved on a broad sense, but much progress has been made in the fields of logic and categorization. We tackled deductive reasoning last lab with logic puzzles, deducing a conclusion of what must be true from the facts presented to us. Today we'll focus on inductive logic: our ability to make generalizations based on data and apply these general rules to new situations.

Step 1

Table of Mushrooms Training Data

edible?gill_spacing (in mm)cap_shapecolorbruisesring_number
edible10"flat""gray"True2
edible17"conical""gray"False0
edible2"sunken""brown"True1
edible15"knobbed""gray"False2
edible1"conical""brown"True0
poisonous4"flat""red"True0
poisonous8"bell""brown"False1
poisonous24"knobbed""red"False0
poisonous16"flat""yellow"False1
poisonous4"knobbed""brown"False1

Imagine you are tasked by the Audobon Society to develop an electronic field guide on mushrooms. They present you with the following ten example mushrooms above, listing a few of their attributes. The most important category is if a mushroom is edible or not, however, this is the only category you cannot directly observe from the mushroom without eating it. They would like a way to make decisions about newly found mushrooms which is based on the information above, and simple enough for someone to remember the edible rule even without the field guide.

Using what you know about if-elif-else statements, write a python program called mushroom_detector.py. First, ask the user to input the data they observe on a single mushroom, using gill_spacing, cap_shape, color, bruises and ring_number. Using this data, construct four if-elif-else statements that will correctly categorize all of the above training data mushrooms, using the following restrictions for each statement:

  1. Only use color and bruises
  2. Only use gill_spacing
  3. Only use cap_shape and ring_number
  4. Uses the least number of boolean operators (and, or, <=, etc)
Output to the user the classification found by each statement, either "edible" or "poisonous", so that you will have four independent judgements made, saying "edible" or "poisonous" for each one.

Step 2

We now wish to evaluate how your field guide will work on unseen data. Test your mushroom_detector.py program with the following data. What is the predicted value for edible/poisonous for each mushroom on each statement? Which statement would you recommend using?
Table of Mushrooms Test Data

gill_spacing (in mm)cap_shapecolorbruisesring_number
4"sunken""red"False1
13"bell""red"True2

What To Hand In

Log in to cs.centenary.edu through either Secure FTP or WinSCP using your cs login and password. Create a subdirectory from csc207 called lab6. Write up your four if-elif-else statements from step 1 in a file called mushroom_detector.py. Write the results of each test example in step 2 with each if-elif-else statement above into a file called lab6_evaluation.txt and copy it into this directory.

You must hand in:


© Mark Goadrich 2007, Centenary College of Louisiana