History of uci_mushroom
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Remove superfluous details of the upstream distribution from the descriptions dc07aa0
The descriptions mentioned incidental details of how the upstream data are made available: the file formats (CSV, JSON, XML, GEXF, SBML, HIF, Pajek, UCINET, ...), file names, where the files were published or obtained from (Zenodo, figshare, Kaggle, the Pajek datasets page, the Internet Archive), and that some networks are only available in the gt format. These are left out; caveats about the data themselves are kept, referring to "the data" instead of "the file". The description of sp_baboons now lists its properties instead of the upstream columns, and says that events without a recipient are left out.
diff --git a/entries/uci_mushroom/__init__.py b/entries/uci_mushroom/__init__.py
index cfa705a..c50100c 100644
--- a/entries/uci_mushroom/__init__.py
+++ b/entries/uci_mushroom/__init__.py
@@ -19,17 +19,17 @@
from .. import *
title = "UCI Mushroom attributes (1981)"
-description = """A bipartite network of mushroom samples and their attribute values, from the "Mushroom" dataset of the UCI Machine Learning Repository, donated by J. Schlimmer in 1987. The 8,124 records are descriptions of hypothetical samples of 23 species of gilled mushrooms of the Agaricus and Lepiota families, drawn from The Audubon Society Field Guide to North American Mushrooms (1981), each described by 22 nominal attributes of the cap, gills, stalk, veil, ring, spore print, population and habitat. Each sample is labelled as edible or poisonous, where species of unknown edibility were merged with the poisonous ones. Each sample is connected to one node for each of its attribute values (e.g. "odor=almond"). The attribute "stalk-root" is missing for 2,480 samples, which therefore have no edge for that attribute (degree 21 instead of 22).
+description = """A bipartite network of mushroom samples and their attribute values, from the "Mushroom" dataset of the UCI Machine Learning Repository, donated by J. Schlimmer in 1987. The 8,124 records are descriptions of hypothetical samples of 23 species of gilled mushrooms of the Agaricus and Lepiota families, drawn from The Audubon Society Field Guide to North American Mushrooms (1981), each described by 22 nominal attributes of the cap, gills, stalk, veil, ring, spore print, population and habitat. Each sample is labeled as edible or poisonous, where species of unknown edibility were merged with the poisonous ones. Each sample is connected to one node for each of its attribute values (e.g. "odor=almond"). The attribute "stalk-root" is missing for 2,480 samples, which therefore have no edge for that attribute (degree 21 instead of 22).
The network has the following properties:
- (Node) `name`: the attribute value in the form "attribute=value" (empty for samples).
- (Node) `is_attribute`: whether the node is an attribute value (otherwise a mushroom sample).
- (Node) `poisonous` (samples): whether the sample is classified as poisonous (or of unknown edibility), otherwise it is edible.
-- (Node) `index` (samples): the position of the record in the source file (starting from 0).
+- (Node) `index` (samples): the position of the record in the data (starting from 0).
- (Node) `attribute` (attributes): the attribute name (e.g. "cap-shape").
- (Node) `value` (attributes): the attribute value (e.g. "convex").
-- (Node) `code` (attributes): the one-letter code of the value in the source file."""
+- (Node) `code` (attributes): the one-letter code of the value in the data."""
tags = ['Biological', 'Unweighted', 'Metadata']
url = 'https://archive.ics.uci.edu/dataset/73/mushroom'
citation = [('"Mushroom [Dataset]." UCI Machine Learning Repository (1981)', 'https://doi.org/10.24432/C5959T')]
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/uci_mushroom/__init__.py b/entries/uci_mushroom/__init__.py
index cc735e9..cfa705a 100644
--- a/entries/uci_mushroom/__init__.py
+++ b/entries/uci_mushroom/__init__.py
@@ -33,7 +33,7 @@ The network has the following properties:
tags = ['Biological', 'Unweighted', 'Metadata']
url = 'https://archive.ics.uci.edu/dataset/73/mushroom'
citation = [('"Mushroom [Dataset]." UCI Machine Learning Repository (1981)', 'https://doi.org/10.24432/C5959T')]
-icon_hash = None
+date_added = '2026-10-25'
upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
upstream_prefix = 'https://archive.ics.uci.edu/static/public/73'
files = [('mushroom.zip:agaricus-lepiota.data', None, None)]
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/uci_mushroom/__init__.py b/entries/uci_mushroom/__init__.py
index 563a0a1..cc735e9 100644
--- a/entries/uci_mushroom/__init__.py
+++ b/entries/uci_mushroom/__init__.py
@@ -23,9 +23,13 @@ description = """A bipartite network of mushroom samples and their attribute val
The network has the following properties:
-- Nodes: `name`, the attribute value in the form "attribute=value" (empty for samples); `is_attribute`, whether the node is an attribute value (otherwise a mushroom sample).
-- Sample nodes: `poisonous`, whether the sample is classified as poisonous (or of unknown edibility), otherwise it is edible; `index`, the position of the record in the source file (starting from 0).
-- Attribute nodes: `attribute`, the attribute name (e.g. "cap-shape"); `value`, the attribute value (e.g. "convex"); `code`, the one-letter code of the value in the source file."""
+- (Node) `name`: the attribute value in the form "attribute=value" (empty for samples).
+- (Node) `is_attribute`: whether the node is an attribute value (otherwise a mushroom sample).
+- (Node) `poisonous` (samples): whether the sample is classified as poisonous (or of unknown edibility), otherwise it is edible.
+- (Node) `index` (samples): the position of the record in the source file (starting from 0).
+- (Node) `attribute` (attributes): the attribute name (e.g. "cap-shape").
+- (Node) `value` (attributes): the attribute value (e.g. "convex").
+- (Node) `code` (attributes): the one-letter code of the value in the source file."""
tags = ['Biological', 'Unweighted', 'Metadata']
url = 'https://archive.ics.uci.edu/dataset/73/mushroom'
citation = [('"Mushroom [Dataset]." UCI Machine Learning Repository (1981)', 'https://doi.org/10.24432/C5959T')]
[entries] Remove unneeded code from the entries 2c69f19
Unneeded "global files" statements, unused imports and variables, f-strings without placeholders, duplicate keys in foodweb_little_rock (keeping the order and the values used), and the second definition of get_lines() in twitter_higgs. Nothing changes in the networks or descriptions. Changed: none
diff --git a/entries/uci_mushroom/__init__.py b/entries/uci_mushroom/__init__.py
index c1f3ca8..563a0a1 100644
--- a/entries/uci_mushroom/__init__.py
+++ b/entries/uci_mushroom/__init__.py
@@ -69,7 +69,6 @@ def fetch_upstream(force=False):
@coerce_props()
@annotate()
def parse(alts=None):
- global files
name = __name__.split(".")[-1]
for fnames, alt, fmt in files:
if alts is not None and alt not in alts:
[entries] New entry: uci_mushroom 87c0b3f
diff --git a/entries/uci_mushroom/__init__.py b/entries/uci_mushroom/__init__.py
new file mode 100644
index 0000000..c1f3ca8
--- /dev/null
+++ b/entries/uci_mushroom/__init__.py
@@ -0,0 +1,112 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "UCI Mushroom attributes (1981)"
+description = """A bipartite network of mushroom samples and their attribute values, from the "Mushroom" dataset of the UCI Machine Learning Repository, donated by J. Schlimmer in 1987. The 8,124 records are descriptions of hypothetical samples of 23 species of gilled mushrooms of the Agaricus and Lepiota families, drawn from The Audubon Society Field Guide to North American Mushrooms (1981), each described by 22 nominal attributes of the cap, gills, stalk, veil, ring, spore print, population and habitat. Each sample is labelled as edible or poisonous, where species of unknown edibility were merged with the poisonous ones. Each sample is connected to one node for each of its attribute values (e.g. "odor=almond"). The attribute "stalk-root" is missing for 2,480 samples, which therefore have no edge for that attribute (degree 21 instead of 22).
+
+The network has the following properties:
+
+- Nodes: `name`, the attribute value in the form "attribute=value" (empty for samples); `is_attribute`, whether the node is an attribute value (otherwise a mushroom sample).
+- Sample nodes: `poisonous`, whether the sample is classified as poisonous (or of unknown edibility), otherwise it is edible; `index`, the position of the record in the source file (starting from 0).
+- Attribute nodes: `attribute`, the attribute name (e.g. "cap-shape"); `value`, the attribute value (e.g. "convex"); `code`, the one-letter code of the value in the source file."""
+tags = ['Biological', 'Unweighted', 'Metadata']
+url = 'https://archive.ics.uci.edu/dataset/73/mushroom'
+citation = [('"Mushroom [Dataset]." UCI Machine Learning Repository (1981)', 'https://doi.org/10.24432/C5959T')]
+icon_hash = None
+upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
+upstream_prefix = 'https://archive.ics.uci.edu/static/public/73'
+files = [('mushroom.zip:agaricus-lepiota.data', None, None)]
+
+# Attributes and value codes, from agaricus-lepiota.names
+_attrs = [
+ ("cap-shape", "bell=b,conical=c,convex=x,flat=f,knobbed=k,sunken=s"),
+ ("cap-surface", "fibrous=f,grooves=g,scaly=y,smooth=s"),
+ ("cap-color", "brown=n,buff=b,cinnamon=c,gray=g,green=r,pink=p,purple=u,red=e,white=w,yellow=y"),
+ ("bruises", "bruises=t,no=f"),
+ ("odor", "almond=a,anise=l,creosote=c,fishy=y,foul=f,musty=m,none=n,pungent=p,spicy=s"),
+ ("gill-attachment", "attached=a,descending=d,free=f,notched=n"),
+ ("gill-spacing", "close=c,crowded=w,distant=d"),
+ ("gill-size", "broad=b,narrow=n"),
+ ("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"),
+ ("stalk-shape", "enlarging=e,tapering=t"),
+ ("stalk-root", "bulbous=b,club=c,cup=u,equal=e,rhizomorphs=z,rooted=r"),
+ ("stalk-surface-above-ring", "fibrous=f,scaly=y,silky=k,smooth=s"),
+ ("stalk-surface-below-ring", "fibrous=f,scaly=y,silky=k,smooth=s"),
+ ("stalk-color-above-ring", "brown=n,buff=b,cinnamon=c,gray=g,orange=o,pink=p,red=e,white=w,yellow=y"),
+ ("stalk-color-below-ring", "brown=n,buff=b,cinnamon=c,gray=g,orange=o,pink=p,red=e,white=w,yellow=y"),
+ ("veil-type", "partial=p,universal=u"),
+ ("veil-color", "brown=n,orange=o,white=w,yellow=y"),
+ ("ring-number", "none=n,one=o,two=t"),
+ ("ring-type", "cobwebby=c,evanescent=e,flaring=f,large=l,none=n,pendant=p,sheathing=s,zone=z"),
+ ("spore-print-color", "black=k,brown=n,buff=b,chocolate=h,green=r,orange=o,purple=u,white=w,yellow=y"),
+ ("population", "abundant=a,clustered=c,numerous=n,scattered=s,several=v,solitary=y"),
+ ("habitat", "grasses=g,leaves=l,meadows=m,paths=p,urban=u,waste=w,woods=d")]
+_attrs = [(a, {c: x for x, c in (kv.split("=") for kv in vals.split(","))})
+ for a, vals in _attrs]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ if isinstance(fnames, str):
+ fnames = [fnames]
+ with ExitStack() as stack:
+ fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+
+ # Columns: class (e/p), followed by the 22 attribute codes; '?'
+ # means missing
+ rows = [r for r in csv.reader(fs[0]) if len(r) > 0]
+
+ g = Graph(directed=False)
+ g.vp.name = g.new_vp("string")
+ g.vp.is_attribute = g.new_vp("bool")
+ g.vp.poisonous = g.new_vp("bool")
+ g.vp.index = g.new_vp("int")
+ g.vp.attribute = g.new_vp("string")
+ g.vp.value = g.new_vp("string")
+ g.vp.code = g.new_vp("string")
+ g.add_vertex(len(rows))
+ for v, r in enumerate(rows):
+ assert r[0] in ("e", "p")
+ g.vp.poisonous[v] = r[0] == "p"
+ g.vp.index[v] = v
+ # Attribute values that occur, in order of attribute and code
+ avs = {}
+ for i, (a, codes) in enumerate(_attrs):
+ for c in sorted(set(r[i + 1] for r in rows) - {"?"}):
+ v = g.add_vertex()
+ avs[(i, c)] = v
+ g.vp.name[v] = f"{a}={codes[c]}"
+ g.vp.is_attribute[v] = True
+ g.vp.attribute[v] = a
+ g.vp.value[v] = codes[c]
+ g.vp.code[v] = c
+ g.add_edge_list([(u, avs[(i, c)]) for u, r in enumerate(rows)
+ for i, c in enumerate(r[1:]) if c != "?"])
+ yield alt, g