qumin.lattice package

Submodules

qumin.lattice.lattice module

class qumin.lattice.lattice.ICLattice(onehot_encoding, leaves, annotate=None, comp_prefix=None, aoc=False, keep_names=False)[source]

Bases: object

Inflection class Lattice representation.

This is a wrapper around (concepts.Context). It builds on concepts’ lattice class, but adopts a custom representation of lattices, using Qumin’s :class:`qumin.clustering.node.Node class.

Variables:
  • context (concepts.Context) – stores the underlying Context.

  • lattice (concepts.lattices.Lattice) – shortcut to the underlying lattice.

  • nodes (qumin.clustering.node.Node) – Qumin’s lattice is represented as a root node. Each node contains its children. This is the lattice we will draw.

  • comp – ?.

  • leaves – dictionary of object properties (typically microclasses). The format is: {<object label>: {‘size’: <size>, ‘other’: <prop>}}. If the size argument is provided, it will be used to render the nodes.

__init__(onehot_encoding, leaves, annotate=None, comp_prefix=None, aoc=False, keep_names=False)[source]
Parameters:
  • onehot_encoding (pandas.DataFrame) – onehot encoding of objects (rows) and attributes (columns). Filled with 1/0, True/False, “X”/””.

  • leaves (dict) – Dictionary of microclasses.

  • annotate (dict) – Extra annotations to add on lattice. Of the form: {<object label>: <annotation>}

  • aoc (bool) – Whether to limit ourselves to Attribute or Object Concepts.

  • keep_names – ? TODO, this option is apparently not implemented.

  • kwargs – all other keyword arguments are passed to table_to_context

ancestors(identifier)[source]

Return all ancestors of a node which corresponds to the identifier.

draw(filename, title='Lattice', **kwargs)[source]

Wrapper around :method:`ICLattice.draw_nodes`.

Parameters:
  • filename (str) – filename of the exported plot.

  • title (str) – title of the plot of the file.

  • **kwargs – keyword arguments are passed to ÌCLattice.draw_nodes().

draw_nodes(figsize=(24, 12), scale=False, colormap='Blues', point=None, **kwargs)[source]

Draw the root node using qumin.clustering.node.Node’s drawing function.

Parameters:
  • figsize (tuple) – Size of the figure.

  • scale (bool) – Whether to display a colorbar. Defaults to False.

  • colormap (str)

  • point

  • **kwargs – All keyword arguments will be passed to qumin.clustering.node.Node.draw().

classmethod from_patterns(patterns, paradigms, **kwargs)[source]

Creates a Lattice from a patterns object.

Parameters:
parents(identifier)[source]

Return all direct parents of a node which corresponds to the identifier.

stats()[source]

Returns some stats about the classification size and shape. Based on self.nodes, not self.lattice: stats are different depending on AOC/not AOC.

to_html(**kwargs)[source]
qumin.lattice.lattice.context_from_pandas(df)[source]

Converts a onehot encoding stored as a pandas.DataFrame to a concepts.Context. Uses the following recipe: https://concepts.readthedocs.io/en/stable/advanced.html#context-from-pandas-dataframe

Parameters:

df (pandas.DataFrame) – onehot encoding of objects (rows) and attributes (columns). Filled with 1/0, True/False or “X”/””.

Returns:

a Context representing the input data.

Return type:

concepts.Context

qumin.lattice.lattice.to_html_disabled(*args, **kwargs)[source]

Module contents