logo Netzschleuder network catalog, repository, and centrifuge

History of uci_zoo

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] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto 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_zoo/__init__.py b/entries/uci_zoo/__init__.py
index 8f7b83f..ca3f3a6 100644
--- a/entries/uci_zoo/__init__.py
+++ b/entries/uci_zoo/__init__.py
@@ -32,7 +32,7 @@ The network has the following properties:
 tags = ['Biological', 'Unweighted', 'Metadata']
 url = 'https://archive.ics.uci.edu/dataset/111/zoo'
 citation = [('R. Forsyth, "Zoo [Dataset]." UCI Machine Learning Repository (1990)', 'https://doi.org/10.24432/C5R59V')]
-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/111'
 files = [('zoo.zip:zoo.data', None, None)]
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto 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_zoo/__init__.py b/entries/uci_zoo/__init__.py
index 19cb86d..8f7b83f 100644
--- a/entries/uci_zoo/__init__.py
+++ b/entries/uci_zoo/__init__.py
@@ -23,9 +23,12 @@ description = """A bipartite network of animals and their attribute values, from
 
 The network has the following properties:
 
-- Nodes: `name`, the animal name, the attribute name, or the number of legs in the form "legs=value"; `is_attribute`, whether the node is an attribute (otherwise an animal).
-- Animal nodes: `type`, the class of the animal as given in the source (1-7); `type_name`, a name for the class (mammal, bird, reptile, fish, amphibian, insect, invertebrate); the source gives only the class numbers, and these names were assigned here from the animals listed for each class in the dataset documentation.
-- Attribute nodes: `attribute`, the attribute name; `value`, its value (always 1 for the boolean attributes, the number of legs for "legs")."""
+- (Node) `name`: the animal name, the attribute name, or the number of legs in the form "legs=value".
+- (Node) `is_attribute`: whether the node is an attribute (otherwise an animal).
+- (Node) `type` (animals): the class of the animal as given in the source (1-7).
+- (Node) `type_name` (animals): a name for the class (mammal, bird, reptile, fish, amphibian, insect, invertebrate); the source gives only the class numbers, and these names were assigned here from the animals listed for each class in the dataset documentation.
+- (Node) `attribute` (attributes): the attribute name.
+- (Node) `value` (attributes): its value (always 1 for the boolean attributes, the number of legs for "legs")."""
 tags = ['Biological', 'Unweighted', 'Metadata']
 url = 'https://archive.ics.uci.edu/dataset/111/zoo'
 citation = [('R. Forsyth, "Zoo [Dataset]." UCI Machine Learning Repository (1990)', 'https://doi.org/10.24432/C5R59V')]
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 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_zoo/__init__.py b/entries/uci_zoo/__init__.py
index 7178b39..19cb86d 100644
--- a/entries/uci_zoo/__init__.py
+++ b/entries/uci_zoo/__init__.py
@@ -50,7 +50,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_zoo by Tiago de Paula Peixoto dc169d7
diff --git a/entries/uci_zoo/__init__.py b/entries/uci_zoo/__init__.py
new file mode 100644
index 0000000..7178b39
--- /dev/null
+++ b/entries/uci_zoo/__init__.py
@@ -0,0 +1,98 @@
+#! /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 Zoo animal attributes (1990)"
+description = """A bipartite network of animals and their attribute values, from the "Zoo" dataset of the UCI Machine Learning Repository, created by R. Forsyth in 1990 as an example database for his PC/BEAGLE rule-induction program. The data describe 101 animals by 15 boolean attributes (hair, feathers, eggs, milk, airborne, aquatic, predator, toothed, backbone, breathes, venomous, fins, tail, domestic, catsize) and their number of legs (0, 2, 4, 5, 6 or 8). There is one attribute node for each boolean attribute (e.g. "hair"), to which the animals that have the attribute are connected, and one node for each number of legs (e.g. "legs=4"), to which each animal with that number of legs is connected. The class of each animal (mammal, bird, etc.) is kept as a node property. The name "frog" appears twice in the source, for two records that differ only in the "venomous" attribute; both are kept as separate nodes.
+
+The network has the following properties:
+
+- Nodes: `name`, the animal name, the attribute name, or the number of legs in the form "legs=value"; `is_attribute`, whether the node is an attribute (otherwise an animal).
+- Animal nodes: `type`, the class of the animal as given in the source (1-7); `type_name`, a name for the class (mammal, bird, reptile, fish, amphibian, insect, invertebrate); the source gives only the class numbers, and these names were assigned here from the animals listed for each class in the dataset documentation.
+- Attribute nodes: `attribute`, the attribute name; `value`, its value (always 1 for the boolean attributes, the number of legs for "legs")."""
+tags = ['Biological', 'Unweighted', 'Metadata']
+url = 'https://archive.ics.uci.edu/dataset/111/zoo'
+citation = [('R. Forsyth, "Zoo [Dataset]." UCI Machine Learning Repository (1990)', 'https://doi.org/10.24432/C5R59V')]
+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/111'
+files = [('zoo.zip:zoo.data', None, None)]
+
+_attrs = ["hair", "feathers", "eggs", "milk", "airborne", "aquatic", "predator",
+          "toothed", "backbone", "breathes", "venomous", "fins", "legs", "tail",
+          "domestic", "catsize"]
+# Class names (not given in the source), inferred from the animals listed
+# for each class in zoo.names
+_types = {1: "mammal", 2: "bird", 3: "reptile", 4: "fish", 5: "amphibian",
+          6: "insect", 7: "invertebrate"}
+
+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: animal name, 16 attributes, type
+            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.type = g.new_vp("int")
+            g.vp.type_name = g.new_vp("string")
+            g.vp.attribute = g.new_vp("string")
+            g.vp.value = g.new_vp("int")
+            g.add_vertex(len(rows))
+            for v, r in enumerate(rows):
+                g.vp.name[v] = r[0]
+                g.vp.type[v] = int(r[17])
+                g.vp.type_name[v] = _types[int(r[17])]
+            avs = {}
+            # Attribute nodes, in order of attribute and value: one node for
+            # each boolean attribute (for the value 1, i.e. its presence), and
+            # one node for each number of legs
+            for i, a in enumerate(_attrs):
+                xs = sorted(set(int(r[i + 1]) for r in rows))
+                if a != "legs":
+                    xs = [x for x in xs if x == 1]
+                for x in xs:
+                    v = g.add_vertex()
+                    avs[(a, x)] = v
+                    g.vp.name[v] = f"{a}={x}" if a == "legs" else a
+                    g.vp.is_attribute[v] = True
+                    g.vp.attribute[v] = a
+                    g.vp.value[v] = x
+            for u, r in enumerate(rows):
+                for i, a in enumerate(_attrs):
+                    v = avs.get((a, int(r[i + 1])))
+                    if v is not None:
+                        g.add_edge(u, v)
+        yield alt, g