simpful

A friendly python library for fuzzy logic reasoning

https://github.com/aresio/simpful

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    3 of 8 committers (37.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.7%) to scientific vocabulary

Keywords

api fuzzy-logic mamdani sugeno
Last synced: 6 months ago · JSON representation

Repository

A friendly python library for fuzzy logic reasoning

Basic Info
  • Host: GitHub
  • Owner: aresio
  • License: afl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 5.8 MB
Statistics
  • Stars: 139
  • Watchers: 7
  • Forks: 36
  • Open Issues: 10
  • Releases: 20
Topics
api fuzzy-logic mamdani sugeno
Created over 7 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

Python package Documentation Status

simpful

A Python library for fuzzy logic reasoning, designed to provide a simple and lightweight API, as close as possible to natural language. Simpful supports Mamdani and Sugeno reasoning of any order, parsing any complex fuzzy rules involving AND, OR, and NOT operators, using arbitrarily shaped fuzzy sets. For more information on its usage, try out the example scripts in this repository or check our online documentation.

Installation

pip install simpful

Citing Simpful

If you find Simpful useful for your research, please cite our work as follows:

Spolaor S., Fuchs C., Cazzaniga P., Kaymak U., Besozzi D., Nobile M.S.: Simpful: a user-friendly Python library for fuzzy logic, International Journal of Computational Intelligence Systems, 13(1):1687–1698, 2020 DOI:10.2991/ijcis.d.201012.002

Usage example 1: controlling a gas burner with a Takagi-Sugeno fuzzy system

This example shows how to specify the information about the linguistic variables, fuzzy sets, fuzzy rules, and input values to Simpful. The last line of code prints the result of the fuzzy reasoning.

``` import simpful as sf

A simple fuzzy model describing how the heating power of a gas burner depends on the oxygen supply.

FS = sf.FuzzySystem()

Define a linguistic variable.

S1 = sf.FuzzySet( points=[[0, 1.], [1., 1.], [1.5, 0]], term="lowflow" ) S2 = sf.FuzzySet( points=[[0.5, 0], [1.5, 1.], [2.5, 1], [3., 0]], term="mediumflow" ) S3 = sf.FuzzySet( points=[[2., 0], [2.5, 1.], [3., 1.]], term="highflow" ) FS.addlinguisticvariable("OXI", sf.LinguisticVariable( [S1, S2, S_3] ))

Define consequents.

FS.setcrispoutputvalue("LOWPOWER", 0) FS.setcrispoutputvalue("MEDIUMPOWER", 25) FS.setoutputfunction("HIGH_FUN", "OXI**2")

Define fuzzy rules.

RULE1 = "IF (OXI IS lowflow) THEN (POWER IS LOWPOWER)" RULE2 = "IF (OXI IS mediumflow) THEN (POWER IS MEDIUMPOWER)" RULE3 = "IF (NOT (OXI IS lowflow)) THEN (POWER IS HIGHFUN)" FS.add_rules([RULE1, RULE2, RULE3])

Set antecedents values, perform Sugeno inference and print output values.

FS.setvariable("OXI", .51) print (FS.Sugenoinference(['POWER'])) ```

Usage example 2: tipping with a Mamdani fuzzy system

This second example shows how to model a FIS using Mamdani inference. It also shows some facilities that make modeling more concise and clear: automatic Triangles (i.e., pre-baked linguistic variables with equally spaced triangular fuzzy sets) and the automatic detection of the inference method.

``` from simpful import *

FS = FuzzySystem()

TLV = AutoTriangle(3, terms=['poor', 'average', 'good'], universeofdiscourse=[0,10]) FS.addlinguisticvariable("service", TLV) FS.addlinguisticvariable("quality", TLV)

O1 = TriangleFuzzySet(0,0,13, term="low") O2 = TriangleFuzzySet(0,13,25, term="medium") O3 = TriangleFuzzySet(13,25,25, term="high") FS.addlinguisticvariable("tip", LinguisticVariable([O1, O2, O3], universeofdiscourse=[0,25]))

FS.add_rules([ "IF (quality IS poor) OR (service IS poor) THEN (tip IS low)", "IF (service IS average) THEN (tip IS medium)", "IF (quality IS good) OR (service IS good) THEN (tip IS high)" ])

FS.setvariable("quality", 6.5) FS.setvariable("service", 9.8)

tip = FS.inference() ```

Usage example 3: fuzzy sets naming

This example shows how to automatically assign names to fuzzy sets. Such a tool can be handy when dealing with automatically genereted Fuzzy Systems.

``` from simpful import * from simpful.clusterlabeling import approximatefs_labels

------ EXAMPLE FUZZY SYSTEM ------

FS = FuzzySystem()

Input Variable 1: Temperature

TS1 = FuzzySet(function=GaussianMF(mu=0, sigma=8), term="cold") TS2 = FuzzySet(function=GaussianMF(mu=40, sigma=8), term="hot") Temperature = LinguisticVariable([TS1, TS2], concept="Temperature", universeofdiscourse=[0, 40]) FS.addlinguisticvariable("Temperature", Temperature)

Input Variable 2: Humidity

HS1 = FuzzySet(function=GaussianMF(mu=0, sigma=20), term="dry") HS2 = FuzzySet(function=GaussianMF(mu=100, sigma=20), term="wet") Humidity = LinguisticVariable([HS1, HS2], concept="Humidity", universeofdiscourse=[0, 100]) FS.addlinguisticvariable("Humidity", Humidity)

Output Variable

FS1 = FuzzySet(function=GaussianMF(mu=0, sigma=25), term="slow") FS2 = FuzzySet(function=GaussianMF(mu=100, sigma=25), term="fast") FanSpeed = LinguisticVariable([FS1, FS2], concept="Fan Speed", universeofdiscourse=[0, 100])

R1 = "IF (Temperature IS hot) AND (Humidity IS wet) THEN (FanSpeed IS fast)" R2 = "IF (Temperature IS cold) THEN (FanSpeed IS slow)" FS.add_rules([R1, R2])

------ USAGE EXAMPLE ------

The generate_report parameter allows the creation of a PDF report with graphs and rules.

The plotcolorbyruleoutput allows to color membership functions based on their rule effect

approximatefslabels(FS, outputpath="output", generatereport=False, plotcolorbyruleoutput=True) ```

Additional examples

Additional example scripts are available in the examples folder of this GitHub and in our Code Ocean capsule.

Further info

Created by Marco S. Nobile at the Eindhoven University of Technology and Simone Spolaor at the University of Milano-Bicocca.

If you need further information, please write an e-mail at: marco.nobile@unive.it.

Owner

  • Name: Marco S. Nobile
  • Login: aresio
  • Kind: user
  • Location: Venice, Italy
  • Company: Ca' Foscari University

I have a BS, MS and Ph.D. in Computer Science. I am a Associate Professor at the Ca' Foscari University of Venice

GitHub Events

Total
  • Issues event: 1
  • Watch event: 11
  • Push event: 1
  • Pull request event: 2
  • Fork event: 2
Last Year
  • Issues event: 1
  • Watch event: 11
  • Push event: 1
  • Pull request event: 2
  • Fork event: 2

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 210
  • Total Committers: 8
  • Avg Commits per committer: 26.25
  • Development Distribution Score (DDS): 0.71
Past Year
  • Commits: 31
  • Committers: 4
  • Avg Commits per committer: 7.75
  • Development Distribution Score (DDS): 0.581
Top Committers
Name Email Commits
Simone Spolaor s****r@c****t 61
MSN m****e@t****l 45
Simone Spolaor s****r@u****t 37
Marco S. Nobile n****e@d****t 33
Nikhilrs1993 3****3 15
Simone Spolaor s****r@t****l 11
Marco S. Nobile m****e@u****t 6
akdenizince 1****e 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 20
  • Total pull requests: 13
  • Average time to close issues: 6 months
  • Average time to close pull requests: 5 months
  • Total issue authors: 16
  • Total pull request authors: 8
  • Average comments per issue: 1.65
  • Average comments per pull request: 0.38
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 minutes
  • Issue authors: 1
  • Pull request authors: 4
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ZA0068 (4)
  • cupressus (2)
  • limgl1998 (1)
  • ggian00 (1)
  • smejkka3 (1)
  • mojtabatorabii (1)
  • jonas-eschle (1)
  • khinggan (1)
  • pbsds (1)
  • tawdes (1)
  • RakshaAg (1)
  • Susi-Eva (1)
  • MtthVt (1)
  • JoseVinicius1998 (1)
  • DManowitz (1)
Pull Request Authors
  • NikhilNRS (5)
  • Nikhilrs1993 (4)
  • LeoneBacciu (2)
  • DanikVitek (2)
  • guilherme-marcello (2)
  • MattVsTheWorld (2)
  • ggian00 (1)
  • akdenizince (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 13
  • Total downloads:
    • pypi 41,930 last-month
  • Total docker downloads: 13,860
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 65
    (may contain duplicates)
  • Total versions: 108
  • Total maintainers: 3
pypi.org: simpful

A user-friendly Python library for fuzzy logic

  • Versions: 85
  • Dependent Packages: 3
  • Dependent Repositories: 65
  • Downloads: 41,930 Last month
  • Docker Downloads: 13,860
Rankings
Downloads: 1.2%
Docker downloads count: 1.4%
Dependent repos count: 1.8%
Average: 4.0%
Dependent packages count: 4.8%
Stargazers count: 7.1%
Forks count: 7.5%
Maintainers (2)
Last synced: 6 months ago
alpine-v3.18: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 10.0%
Stargazers count: 20.0%
Forks count: 20.2%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.18: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 10.0%
Stargazers count: 20.0%
Forks count: 20.2%
Maintainers (1)
Last synced: 6 months ago
alpine-edge: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 14.6%
Dependent packages count: 14.6%
Stargazers count: 21.7%
Forks count: 21.8%
Maintainers (1)
Last synced: 6 months ago
alpine-edge: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 13.3%
Average: 14.7%
Forks count: 22.6%
Stargazers count: 23.0%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.20: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.21: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.21: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.19: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.20: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.22: py3-simpful

A friendly python library for fuzzy logic reasoning

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.19: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Last synced: 6 months ago
alpine-v3.22: py3-simpful-pyc

Precompiled Python bytecode for py3-simpful

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • Sphinx ==3.3.1
  • jinja2 <3.1.0
  • numpy *
  • scipy *
  • sphinx-rtd-theme ==0.5.0
  • sphinxcontrib-napoleon ==0.7
setup.py pypi
  • numpy *
  • requests *
  • scipy *
.github/workflows/python-package.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite