Files
Data-Mining-Mushrooms/notebooks/mushroom_analysis.ipynb
T
2026-10-09 15:03:02 +00:00

9.4 KiB

In [1]:
from sklearn.datasets import fetch_openml

mushroom = fetch_openml(data_id=43922, as_frame=True)

X = mushroom.data
y = mushroom.target

print("Feature data:", X.shape)
print("Target data:", y.shape)
display(X.head())
display(y.head())
print(y.value_counts())
Feature data: (8124, 22)
Target data: (8124,)
cap_shape cap_surface cap_color bruises odor gill_attachment gill_spacing gill_size gill_color stalk_shape ... stalk_surface_below_ring stalk_color_above_ring stalk_color_below_ring veil_type veil_color ring_number ring_type spore-print-color population habitat
0 x s n t p f c n k e ... s w w p w o p k s u
1 x s y t a f c b k e ... s w w p w o p n n g
2 b s w t l f c b n e ... s w w p w o p n n m
3 x y w t p f c n n e ... s w w p w o p k s u
4 x s g f n f w b k t ... s w w p w o e n a g

5 rows × 22 columns

0    p
1    e
2    e
3    p
4    e
Name: class, dtype: category
Categories (2, str): ['e', 'p']
class
e    4208
p    3916
Name: count, dtype: int64
In [2]:
print("Missing cells:", X.isna().sum().sum())
print("Rows with missing cells:", X.isna().any(axis=1).sum())
print(X["stalk_root"].value_counts(dropna=False))
Missing cells: 0
Rows with missing cells: 0
stalk_root
b    3776
?    2480
e    1120
c     556
r     192
Name: count, dtype: int64
In [ ]:
a = "hello"
print(a)