python常见的数据类型形式化定义_concepts-用Python进行形式化概念分析-Sebastian Bank Links Installation Quickstart Further re...

作者:Sebastian Bank

作者邮箱:sebastian.bank@uni-leipzig.de

首页:https://github.com/xflr6/concepts

文档:None

下载链接

Concepts

|PyPI version| |License| |Supported Python| |Format|

|Travis| |Codecov| |Readthedocs-stable| |Readthedocs-latest|

Concepts is a simple Python implementation of Formal Concept Analysis (FCA_).

FCA provides a mathematical model for describing a set of objects (e.g. King Arthur, Sir Robin, and the holy grail) with a set of properties (e.g. human, knight, king, and mysterious) which each of the objects either has or not. A table called formal context defines which objects have a given property and vice versa which properties a given object has.

Links

GitHub: https://github.com/xflr6/concepts

PyPI: https://pypi.org/project/concepts/

Documentation: https://concepts.readthedocs.io

Changelog: https://concepts.readthedocs.io/en/latest/changelog.html

Issue Tracker: https://github.com/xflr6/concepts/issues

Download: https://pypi.org/project/concepts/#files

Installation

This package runs under Python 2.7 and 3.5+, use pip_ to install:

.. code:: bash

$ pip install concepts

This will also install the bitsets_ and graphviz_ packages from PyPI as required dependencies.

Rendering lattice graphs depends on the Graphviz software_. Make sure its dot executable is on your systems' path.

Quickstart

Create a formal context defining which object has which property, e.g. from a simple ASCII-art style cross-table with object rows and property columns (alternatively load a CXT or CSV file):

.. code:: python

>>> from concepts import Context

>>> c = Context.fromstring('''

... |human|knight|king |mysterious|

... King Arthur| X | X | X | |

... Sir Robin | X | X | | |

... holy grail | | | | X |

... ''')

>>> c # doctest: +ELLIPSIS

Query common properties of objects or common objects of properties (derivation):

.. code:: python

>>> c.intension(['King Arthur', 'Sir Robin'])

('human', 'knight')

>>> c.extension(['knight', 'mysterious'])

()

Get the closest matching objects-properties pair of objects or properties (formal concepts):

.. code:: python

>>> c['Sir Robin', 'holy grail']

(('King Arthur', 'Sir Robin', 'holy grail'), ())

>>> c['king',]

(('King Arthur',), ('human', 'knight', 'king'))

Iterate over the concept lattice of all objects-properties pairs:

.. code:: python

>>> for extent, intent in c.lattice:

... print('%r %r' % (extent, intent))

() ('human', 'knight', 'king', 'mysterious')

('King Arthur',) ('human', 'knight', 'king')

('holy grail',) ('mysterious',)

('King Arthur', 'Sir Robin') ('human', 'knight')

('King Arthur', 'Sir Robin', 'holy grail') ()

Make a Graphviz visualization of the lattice (use .graphviz(view=True) to directly render it and display the resulting PDF):

.. code:: python

>>> c.lattice.graphviz() # doctest: +ELLIPSIS

.. image:: https://raw.github.com/xflr6/concepts/master/docs/holy-grail.png :align: center

Further reading

https://en.wikipedia.org/wiki/Formalconceptanalysis

http://www.upriss.org.uk/fca/

The generation of the concept lattice is based on the algorithm from C. Lindig. Fast Concept Analysis_. In Gerhard Stumme, editors, Working with Conceptual Structures - Contributions to ICCS 2000, Shaker Verlag, Aachen, Germany, 2000.

The included example CXT files are taken from Uta Priss' FCA homepage_

See also

The implementation is based on these Python packages:

bitsets_ |--| Ordered subsets over a predefined domain

graphviz_ |--| Simple Python interface for Graphviz

The following package is build on top of concepts:

features_ |--| Feature set algebra for linguistics

If you want to apply FCA to bigger data sets, you might want to consider other implementations_ based on more sophisticated algorithms_ like In-Close_ or Fcbo_.

License

Concepts is distributed under the MIT license_.

.. FCA: https://en.wikipedia.org/wiki/Formalconcept_analysis .. _Fast Concept Analysis: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.143.948 .. _FCA homepage: http://www.upriss.org.uk/fca/examples.html

.. _pip: https://pip.readthedocs.io .. _Graphviz software: http://www.graphviz.org

.. _bitsets: https://pypi.org/project/bitsets/ .. _graphviz: https://pypi.org/project/graphviz/ .. _features: https://pypi.org/project/features/

.. _other implementations: http://www.upriss.org.uk/fca/fcasoftware.html .. _more sophisticated algorithms: http://www.upriss.org.uk/fca/fcaalgorithms.html .. _In-Close: https://sourceforge.net/projects/inclose/ .. _Fcbo: http://fcalgs.sourceforge.net

.. _MIT license: https://opensource.org/licenses/MIT

.. |--| unicode:: U+2013

.. |PyPI version| image:: https://img.shields.io/pypi/v/concepts.svg :target: https://pypi.org/project/concepts/ :alt: Latest PyPI Version .. |License| image:: https://img.shields.io/pypi/l/concepts.svg :target: https://pypi.org/project/concepts/ :alt: License .. |Supported Python| image:: https://img.shields.io/pypi/pyversions/concepts.svg :target: https://pypi.org/project/concepts/ :alt: Supported Python Versions .. |Format| image:: https://img.shields.io/pypi/format/concepts.svg :target: https://pypi.org/project/concepts/ :alt: Format

.. |Travis| image:: https://img.shields.io/travis/xflr6/concepts.svg :target: https://travis-ci.org/xflr6/concepts :alt: Travis .. |Codecov| image:: https://codecov.io/gh/xflr6/concepts/branch/master/graph/badge.svg :target: https://codecov.io/gh/xflr6/concepts :alt: Codecov .. |Readthedocs-stable| image:: https://readthedocs.org/projects/concepts/badge/?version=stable :target: https://concepts.readthedocs.io/en/stable/?badge=stable :alt: Readthedocs stable .. |Readthedocs-latest| image:: https://readthedocs.org/projects/concepts/badge/?version=latest :target: https://concepts.readthedocs.io/en/latest/?badge=latest :alt: Readthedocs latest

Copy from pypi.org

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值