The mushroom dataset detalis

  1. Title: Mushroom Database

  2. Sources:
    1. Mushroom records drawn from The Audubon Society Field Guide to North American Mushrooms (1981). G. H. Lincoff (Pres.), New York: Alfred A. Knopf
    2. Donor: Jeff Schlimmer (Jeffrey.Schlimmer@a.gp.cs.cmu.edu)
    3. Date: 27 April 1987

This data set includes descriptions of hypothetical samples corresponding to 23 species of gilled mushrooms in the Agaricus and Lepiota Family (pp. 500-525). Each species is identified as definitely edible, definitely poisonous, or of unknown edibility and not recommended. This latter class was combined with the poisonous one. The Guide clearly states that there is no simple rule for determining the edibility of a mushroom; no rule like ``leaflets three, let it be’’ for Poisonous Oak and Ivy.

  1. Number of Instances: 8124

  2. Number of Attributes: 22 (all nominally valued)

  3. Attribute Information: (classes: edible=e, poisonous=p)
    1. cap-shape: bell=b,conical=c,convex=x,flat=f, knobbed=k,sunken=s
    2. cap-surface: fibrous=f,grooves=g,scaly=y,smooth=s
    3. cap-color: brown=n,buff=b,cinnamon=c,gray=g,green=r, pink=p,purple=u,red=e,white=w,yellow=y
    4. bruises?: bruises=t,no=f
    5. odor: almond=a,anise=l,creosote=c,fishy=y,foul=f, musty=m,none=n,pungent=p,spicy=s
    6. gill-attachment: attached=a,descending=d,free=f,notched=n
    7. gill-spacing: close=c,crowded=w,distant=d
    8. gill-size: broad=b,narrow=n
    9. gill-color: black=k,brown=n,buff=b,chocolate=h,gray=g, green=r,orange=o,pink=p,purple=u,red=e, white=w,yellow=y
    10. stalk-shape: enlarging=e,tapering=t
    11. stalk-root: bulbous=b,club=c,cup=u,equal=e, rhizomorphs=z,rooted=r,missing=?
    12. stalk-surface-above-ring: fibrous=f,scaly=y,silky=k,smooth=s
    13. stalk-surface-below-ring: fibrous=f,scaly=y,silky=k,smooth=s
    14. stalk-color-above-ring: brown=n,buff=b,cinnamon=c,gray=g,orange=o, pink=p,red=e,white=w,yellow=y
    15. stalk-color-below-ring: brown=n,buff=b,cinnamon=c,gray=g,orange=o, pink=p,red=e,white=w,yellow=y
    16. veil-type: partial=p,universal=u
    17. veil-color: brown=n,orange=o,white=w,yellow=y
    18. ring-number: none=n,one=o,two=t
    19. ring-type: cobwebby=c,evanescent=e,flaring=f,large=l, none=n,pendant=p,sheathing=s,zone=z
    20. spore-print-color: black=k,brown=n,buff=b,chocolate=h,green=r, orange=o,purple=u,white=w,yellow=y
    21. population: abundant=a,clustered=c,numerous=n, scattered=s,several=v,solitary=y
    22. habitat: grasses=g,leaves=l,meadows=m,paths=p, urban=u,waste=w,woods=d
  4. Missing Attribute Values: 2480 of them (denoted by “?”), all for attribute #11.

  5. Class Distribution: – edible: 4208 (51.8%) – poisonous: 3916 (48.2%) – total: 8124 instances

download.file('https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data', 'agaricus-lepiota.data')
mushrooms <- read.table('agaricus-lepiota.data', sep=',', stringsAsFactors=FALSE)
summary(mushrooms)
##       V1                 V2                 V3           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##       V4                 V5                 V6           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##       V7                 V8                 V9           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##      V10                V11                V12           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##      V13                V14                V15           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##      V16                V17                V18           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##      V19                V20                V21           
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##      V22                V23           
##  Length:8124        Length:8124       
##  Class :character   Class :character  
##  Mode  :character   Mode  :character
head(mushrooms)
##   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20
## 1  p  x  s  n  t  p  f  c  n   k   e   e   s   s   w   w   p   w   o   p
## 2  e  x  s  y  t  a  f  c  b   k   e   c   s   s   w   w   p   w   o   p
## 3  e  b  s  w  t  l  f  c  b   n   e   c   s   s   w   w   p   w   o   p
## 4  p  x  y  w  t  p  f  c  n   n   e   e   s   s   w   w   p   w   o   p
## 5  e  x  s  g  f  n  f  w  b   k   t   e   s   s   w   w   p   w   o   e
## 6  e  x  y  y  t  a  f  c  b   n   e   c   s   s   w   w   p   w   o   p
##   V21 V22 V23
## 1   k   s   u
## 2   n   n   g
## 3   n   n   m
## 4   k   s   u
## 5   n   a   g
## 6   k   n   g
dim(mushrooms)
## [1] 8124   23
df <- subset(mushrooms, select = c(V1, V3, V17, V19))

names(df) <- c('class', 'cap-surface', 'veil-type', 'ring-number')
head(df)
##   class cap-surface veil-type ring-number
## 1     p           s         p           o
## 2     e           s         p           o
## 3     e           s         p           o
## 4     p           y         p           o
## 5     e           s         p           o
## 6     e           y         p           o
## Renaming values in the columns

df$class[df$class=="p"]<- "poisonous"
df$class[df$class=="e"]<- "edible"

df['cap-surface'][df['cap-surface']=="f"]<- "fibrous"
df['cap-surface'][df['cap-surface']=="g"]<- "grooves"
df['cap-surface'][df['cap-surface']=="y"]<- "scaly"
df['cap-surface'][df['cap-surface']=="s"]<- "smooth"

df['veil-type'][df['veil-type']=="u"]<- "universal"
df['veil-type'][df['veil-type']=="p"]<- "partial"

df['ring-number'][df['ring-number']=="n"]<- "none"
df['ring-number'][df['ring-number']=="o"]<- "one"
df['ring-number'][df['ring-number']=="t"]<- "two"
summary(df, 30)
##     class           cap-surface         veil-type        
##  Length:8124        Length:8124        Length:8124       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##  ring-number       
##  Length:8124       
##  Class :character  
##  Mode  :character
head(df, 30)
##        class cap-surface veil-type ring-number
## 1  poisonous      smooth   partial         one
## 2     edible      smooth   partial         one
## 3     edible      smooth   partial         one
## 4  poisonous       scaly   partial         one
## 5     edible      smooth   partial         one
## 6     edible       scaly   partial         one
## 7     edible      smooth   partial         one
## 8     edible       scaly   partial         one
## 9  poisonous       scaly   partial         one
## 10    edible      smooth   partial         one
## 11    edible       scaly   partial         one
## 12    edible       scaly   partial         one
## 13    edible      smooth   partial         one
## 14 poisonous       scaly   partial         one
## 15    edible     fibrous   partial         one
## 16    edible     fibrous   partial         one
## 17    edible     fibrous   partial         one
## 18 poisonous      smooth   partial         one
## 19 poisonous       scaly   partial         one
## 20 poisonous      smooth   partial         one
## 21    edible      smooth   partial         one
## 22 poisonous       scaly   partial         one
## 23    edible       scaly   partial         one
## 24    edible       scaly   partial         one
## 25    edible      smooth   partial         one
## 26 poisonous      smooth   partial         one
## 27    edible       scaly   partial         one
## 28    edible       scaly   partial         one
## 29    edible     fibrous   partial         one
## 30    edible      smooth   partial         one