fylearn


Namefylearn JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryFuzzy Machine Learning Algorithms
upload_time2024-06-26 13:36:54
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords machine learning fuzzy logic scikit-learn fuzzy systems
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<img src="docs/img/fylearn.svg" alt="fylearn - fuzzy machine learning" width="300">

[![Build status](https://github.com/sorend/fylearn/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/sorend/fylearn/actions/?query=branch%3Amain)
[![PyPI version](https://badge.fury.io/py/fylearn.svg?branch=main)](https://badge.fury.io/py/fylearn?branch=main)
[![CodeQL](https://github.com/sorend/fylearn/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sorend/fylearn/actions/workflows/codeql-analysis.yml)
[![Codecov](https://codecov.io/gh/sorend/fylearn/branch/main/graph/badge.svg)](https://codecov.io/gh/sorend/fylearn)

fylearn is a fuzzy machine learning library, built on top of [SciKit-Learn](http://scikit-learn.org/).

SciKit-Learn contains many common machine learning algorithms, and is a good place to start if you want to play or program anything related to machine learning in Python. fylearn is not intended to be a replacement for SciKit-Learn (in fact fylearn depends on SciKit-Learn), but to provide an extra set of machine learning algorithms from the fuzzy logic community.

Machine learning algorithms
---------------------------

### Fuzzy pattern classifiers

Fuzzy pattern classifiers are classifiers that describe data using fuzzy sets and fuzzy aggregation functions.

Several fuzzy pattern classifiers are implemented in the library:
 - fylearn.frr.FuzzyReductionRuleClassifier -- based on learning membership functions from min/max.
 - fylearn.fpcga.FuzzyPatternClassifierGA -- optimizes membership functions globally.
 - fylearn.fpcga.FuzzyPatternClassifierLocalGA -- optimizes membership functions locally.
 - fylearn.fpt.FuzzyPatternTreeClassifier -- builds fuzzy pattern trees using bottom-up method.
 - fylearn.fpt.FuzzyPatternTreeTopDownClassifier -- builds fuzzy pattern trees using top-down method.
 - fylearn.nfpc.FuzzyPatternClassifier -- base class for fuzzy pattern classifiers (see parameters).

### Genetic Algorithm rule based classifiers

A type of classifier that uses GA to optimize rules

- fylearn.garules.MultimodalEvolutionaryClassifer -- learns rules using genetic algorithm.


Installation
------------

You can add fylearn to your project by using pip:

    pip install fylearn

### Usage

You can use the classifiers as any other SciKit-Learn classifier:

    from fylearn.nfpc import FuzzyPatternClassifier
    from fylearn.garules import MultimodalEvolutionaryClassifier
    from fylearn.fpt import FuzzyPatternTreeTopDownClassifier

    C = (FuzzyPatternClassifier(),
         MultimodalEvolutionaryClassifier(),
         FuzzyPatternTreeTopDownClassifier())

    for c in C:
        print c.fit(X, y).predict([1, 2, 3, 4])

Heuristic search methods
------------------------

Several heuristic search methods are implemented. These are used in the learning algorithms
for parameter assignment, but, are also usable directly.

 - fylearn.local_search.PatternSearchOptimizer
 - fylearn.local_search.LocalUnimodalSamplingOptimizer
 - fylearn.ga.GeneticAlgorithm: Search parameters using modification and a scaling
 - fylearn.ga.UnitIntervalGeneticAlgorithm: Search parameters in unit interval universe.
 - fylearn.ga.DiscreteGeneticAlgorithm: Search parameters from discrete universe.
 - fylearn.tlbo.TeachingLearningBasedOptimizer: Search using teaching-learning based optimization.
 - fylearn.jaya.JayaOptimizer: Search based on moving towards best solution while avoiding worst.

Example use:

    import numpy as np
    from fylearn.ga import UnitIntervalGeneticAlgorithm, helper_fitness, helper_n_generations
    from fylearn.local_search import LocalUnimodalSamplingOptimizer, helper_num_runs
    from fylearn.tlbo import TeachingLearningBasedOptimizer
    from fylearn.jaya import JayaOptimizer

    def fitness(x):  # defined for a single chromosome, so we need helper_fitness for GA
        return np.sum(x**2)

    ga = UnitIntervalGeneticAlgorithm(fitness_function=helper_fitness(fitness), n_chromosomes=100, n_genes=10)
    ga = helper_n_generations(ga, 100)
    best_chromosomes, best_fitness = ga.best(1)
    print "GA solution", best_chromosomes[0], "fitness", best_fitness[0]

    lower_bounds, upper_bounds = np.ones(10) * -10., np.ones(10) * 10.
    lus = LocalUnimodalSamplingOptimizer(fitness, lower_bounds, upper_bounds)
    best_solution, best_fitness = helper_num_runs(lus, 100)
    print "LUS solution", best_solution, "fitness", best_fitness

    tlbo = TeachingLearningBasedOptimizer(fitness, lower_bounds, upper_bounds)
    tlbo = helper_n_generations(tlbo, 100)
    best_solution, best_fitness = tlbo.best()
    print "TLBO solution", best_solution, "fitness", best_fitness

    jaya = JayaOptimizer(fitness, lower_bounds, upper_bounds)
    jaya = helper_n_generations(jaya, 100)
    best_solution, best_fitness = jaya.best()
    print "Jaya solution", best_solution, "fitness", best_fitness

A tiny fuzzy logic library
--------------------------

Tiny, but hopefully useful. The focus of the library is on providing membership functions and aggregations that work with NumPy, for using in the implemented learning algorithms.

### Membership functions

 - fylearn.fuzzylogic.TriangularSet
 - fylearn.fuzzylogic.TrapezoidalSet
 - fylearn.fuzzylogic.PiSet

Example use:

    import numpy as np
    from fylearn.fuzzylogic import TriangularSet
    t = TriangularSet(1.0, 4.0, 5.0)
    print t(3)   # use with singletons
    print t(np.array([[1, 2, 3], [4, 5, 6]]))  # use with arrays

### Aggregation functions

Here focus has been on providing aggregation functions that support aggregation along a specified axis for 2-dimensional matrices.

Example use:

    import numpy as np
    from fylearn.fuzzylogic import meowa, OWA
    a = OWA([1.0, 0.0, 0.0])  # pure AND in OWA
    X = np.random.rand(5, 3)
    print a(X)  # AND row-wise
    a = meowa(5, 0.2)  # OR, andness = 0.2
    print a(X.T)  # works column-wise, so apply to transposed X

To Do
-----

We are working on adding the following algorithms:

 - ANFIS.
 - FRBCS.

About
-----

fylearn is supposed to mean "FuzzY learning", but in Danish the word "fy" means loosely translated "for shame". It has been created by the Department of Computer Science at Sri Venkateswara University, Tirupati, INDIA by a [PhD student](http://www.cs.svu-ac.in/~sorend/) as part of his research.

Contributions:
--------------

 - fylearn.local_search Python code by [M. E. H. Pedersen](http://hvass-labs.org/) (M. E. H. Pedersen, *Tuning and Simplifying Heuristical Optimization*, PhD Thesis, University of Southampton, U.K., 2010)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fylearn",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "S\u00f8ren Atmakuri Davidsen <soren@atmakuridavidsen.com>",
    "keywords": "machine learning, fuzzy logic, scikit-learn, fuzzy systems",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d3/71/8c1ebc470d1db2e7d1ac9450bfcd18abf8c94f97d55bcbd6bd6a082a9c47/fylearn-0.2.1.tar.gz",
    "platform": null,
    "description": "\n<img src=\"docs/img/fylearn.svg\" alt=\"fylearn - fuzzy machine learning\" width=\"300\">\n\n[![Build status](https://github.com/sorend/fylearn/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/sorend/fylearn/actions/?query=branch%3Amain)\n[![PyPI version](https://badge.fury.io/py/fylearn.svg?branch=main)](https://badge.fury.io/py/fylearn?branch=main)\n[![CodeQL](https://github.com/sorend/fylearn/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sorend/fylearn/actions/workflows/codeql-analysis.yml)\n[![Codecov](https://codecov.io/gh/sorend/fylearn/branch/main/graph/badge.svg)](https://codecov.io/gh/sorend/fylearn)\n\nfylearn is a fuzzy machine learning library, built on top of [SciKit-Learn](http://scikit-learn.org/).\n\nSciKit-Learn contains many common machine learning algorithms, and is a good place to start if you want to play or program anything related to machine learning in Python. fylearn is not intended to be a replacement for SciKit-Learn (in fact fylearn depends on SciKit-Learn), but to provide an extra set of machine learning algorithms from the fuzzy logic community.\n\nMachine learning algorithms\n---------------------------\n\n### Fuzzy pattern classifiers\n\nFuzzy pattern classifiers are classifiers that describe data using fuzzy sets and fuzzy aggregation functions.\n\nSeveral fuzzy pattern classifiers are implemented in the library:\n - fylearn.frr.FuzzyReductionRuleClassifier -- based on learning membership functions from min/max.\n - fylearn.fpcga.FuzzyPatternClassifierGA -- optimizes membership functions globally.\n - fylearn.fpcga.FuzzyPatternClassifierLocalGA -- optimizes membership functions locally.\n - fylearn.fpt.FuzzyPatternTreeClassifier -- builds fuzzy pattern trees using bottom-up method.\n - fylearn.fpt.FuzzyPatternTreeTopDownClassifier -- builds fuzzy pattern trees using top-down method.\n - fylearn.nfpc.FuzzyPatternClassifier -- base class for fuzzy pattern classifiers (see parameters).\n\n### Genetic Algorithm rule based classifiers\n\nA type of classifier that uses GA to optimize rules\n\n- fylearn.garules.MultimodalEvolutionaryClassifer -- learns rules using genetic algorithm.\n\n\nInstallation\n------------\n\nYou can add fylearn to your project by using pip:\n\n    pip install fylearn\n\n### Usage\n\nYou can use the classifiers as any other SciKit-Learn classifier:\n\n    from fylearn.nfpc import FuzzyPatternClassifier\n    from fylearn.garules import MultimodalEvolutionaryClassifier\n    from fylearn.fpt import FuzzyPatternTreeTopDownClassifier\n\n    C = (FuzzyPatternClassifier(),\n         MultimodalEvolutionaryClassifier(),\n         FuzzyPatternTreeTopDownClassifier())\n\n    for c in C:\n        print c.fit(X, y).predict([1, 2, 3, 4])\n\nHeuristic search methods\n------------------------\n\nSeveral heuristic search methods are implemented. These are used in the learning algorithms\nfor parameter assignment, but, are also usable directly.\n\n - fylearn.local_search.PatternSearchOptimizer\n - fylearn.local_search.LocalUnimodalSamplingOptimizer\n - fylearn.ga.GeneticAlgorithm: Search parameters using modification and a scaling\n - fylearn.ga.UnitIntervalGeneticAlgorithm: Search parameters in unit interval universe.\n - fylearn.ga.DiscreteGeneticAlgorithm: Search parameters from discrete universe.\n - fylearn.tlbo.TeachingLearningBasedOptimizer: Search using teaching-learning based optimization.\n - fylearn.jaya.JayaOptimizer: Search based on moving towards best solution while avoiding worst.\n\nExample use:\n\n    import numpy as np\n    from fylearn.ga import UnitIntervalGeneticAlgorithm, helper_fitness, helper_n_generations\n    from fylearn.local_search import LocalUnimodalSamplingOptimizer, helper_num_runs\n    from fylearn.tlbo import TeachingLearningBasedOptimizer\n    from fylearn.jaya import JayaOptimizer\n\n    def fitness(x):  # defined for a single chromosome, so we need helper_fitness for GA\n        return np.sum(x**2)\n\n    ga = UnitIntervalGeneticAlgorithm(fitness_function=helper_fitness(fitness), n_chromosomes=100, n_genes=10)\n    ga = helper_n_generations(ga, 100)\n    best_chromosomes, best_fitness = ga.best(1)\n    print \"GA solution\", best_chromosomes[0], \"fitness\", best_fitness[0]\n\n    lower_bounds, upper_bounds = np.ones(10) * -10., np.ones(10) * 10.\n    lus = LocalUnimodalSamplingOptimizer(fitness, lower_bounds, upper_bounds)\n    best_solution, best_fitness = helper_num_runs(lus, 100)\n    print \"LUS solution\", best_solution, \"fitness\", best_fitness\n\n    tlbo = TeachingLearningBasedOptimizer(fitness, lower_bounds, upper_bounds)\n    tlbo = helper_n_generations(tlbo, 100)\n    best_solution, best_fitness = tlbo.best()\n    print \"TLBO solution\", best_solution, \"fitness\", best_fitness\n\n    jaya = JayaOptimizer(fitness, lower_bounds, upper_bounds)\n    jaya = helper_n_generations(jaya, 100)\n    best_solution, best_fitness = jaya.best()\n    print \"Jaya solution\", best_solution, \"fitness\", best_fitness\n\nA tiny fuzzy logic library\n--------------------------\n\nTiny, but hopefully useful. The focus of the library is on providing membership functions and aggregations that work with NumPy, for using in the implemented learning algorithms.\n\n### Membership functions\n\n - fylearn.fuzzylogic.TriangularSet\n - fylearn.fuzzylogic.TrapezoidalSet\n - fylearn.fuzzylogic.PiSet\n\nExample use:\n\n    import numpy as np\n    from fylearn.fuzzylogic import TriangularSet\n    t = TriangularSet(1.0, 4.0, 5.0)\n    print t(3)   # use with singletons\n    print t(np.array([[1, 2, 3], [4, 5, 6]]))  # use with arrays\n\n### Aggregation functions\n\nHere focus has been on providing aggregation functions that support aggregation along a specified axis for 2-dimensional matrices.\n\nExample use:\n\n    import numpy as np\n    from fylearn.fuzzylogic import meowa, OWA\n    a = OWA([1.0, 0.0, 0.0])  # pure AND in OWA\n    X = np.random.rand(5, 3)\n    print a(X)  # AND row-wise\n    a = meowa(5, 0.2)  # OR, andness = 0.2\n    print a(X.T)  # works column-wise, so apply to transposed X\n\nTo Do\n-----\n\nWe are working on adding the following algorithms:\n\n - ANFIS.\n - FRBCS.\n\nAbout\n-----\n\nfylearn is supposed to mean \"FuzzY learning\", but in Danish the word \"fy\" means loosely translated \"for shame\". It has been created by the Department of Computer Science at Sri Venkateswara University, Tirupati, INDIA by a [PhD student](http://www.cs.svu-ac.in/~sorend/) as part of his research.\n\nContributions:\n--------------\n\n - fylearn.local_search Python code by [M. E. H. Pedersen](http://hvass-labs.org/) (M. E. H. Pedersen, *Tuning and Simplifying Heuristical Optimization*, PhD Thesis, University of Southampton, U.K., 2010)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Fuzzy Machine Learning Algorithms",
    "version": "0.2.1",
    "project_urls": {
        "Issues": "https://github.com/sorend/fylearn/issues",
        "Repository": "https://github.com/sorend/fylearn.git"
    },
    "split_keywords": [
        "machine learning",
        " fuzzy logic",
        " scikit-learn",
        " fuzzy systems"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b2e4084b15aa2017bb99e50ef505173f81e92f9a37398909db4648e10adb3d6a",
                "md5": "b4ae32e6588aec139b41a0f7d4108d1e",
                "sha256": "903a2e146803c48bc057909782926bbaa6e904f05cae3fd54ae368fa598a5a9f"
            },
            "downloads": -1,
            "filename": "fylearn-0.2.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b4ae32e6588aec139b41a0f7d4108d1e",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 35269,
            "upload_time": "2024-06-26T13:36:53",
            "upload_time_iso_8601": "2024-06-26T13:36:53.167887Z",
            "url": "https://files.pythonhosted.org/packages/b2/e4/084b15aa2017bb99e50ef505173f81e92f9a37398909db4648e10adb3d6a/fylearn-0.2.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d3718c1ebc470d1db2e7d1ac9450bfcd18abf8c94f97d55bcbd6bd6a082a9c47",
                "md5": "237787de4cae4b3e3660e664df3c4399",
                "sha256": "7a4f62889faec47ce7149d4bd9df2fd050a66dd995affe00df63a4b21fcaf99c"
            },
            "downloads": -1,
            "filename": "fylearn-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "237787de4cae4b3e3660e664df3c4399",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 52242,
            "upload_time": "2024-06-26T13:36:54",
            "upload_time_iso_8601": "2024-06-26T13:36:54.883147Z",
            "url": "https://files.pythonhosted.org/packages/d3/71/8c1ebc470d1db2e7d1ac9450bfcd18abf8c94f97d55bcbd6bd6a082a9c47/fylearn-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-26 13:36:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sorend",
    "github_project": "fylearn",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fylearn"
}
        
Elapsed time: 0.27619s