# Mistify
Mistify is a library built on PyTorch for building Neurofuzzy Systems. A neurofuzzy system is a trainable fuzzy system, typically consisting of a fuzzifier, rules layers, and a defuzzifier. Mistify provides a variety of modules to use at each layer of the pipeline
## Installation
```bash
pip install mistify
```
## Brief Overview
Mistify consists of subpackages for inference operations, fuzzification and defuzzification, and preprocessing and postprocessing. It incldes
- **mistify**: The core functions used for fuzzification and inference.
- **mistify.fuzzify**: Modules for building fuzzifiers and defuzzifiers. Has a variety of shapes or other fuzzification and defuzzification modules to use.
- **mistify.infer**: Modules for performing inference operations such as Or Neurons, Intersections, Activations etc.
- **mistify.process**: Modules for preprocessing or postprocessing on the data to input into the fuzzy system
- **mistify.systems**: Modules for building systems more easily.
- **mistify.utils**: Utilities used by other modules in Mistify.
## Usage
Mistify's primary prupose is to build neurofuzzy systems or fuzzy neural networks using the the framework of PyTorch.
Here is a (non-working) example that uses alternating Or and And neurons.
```bash
class FuzzySystem(nn.Module):
def __init__(
self, in_features: int, h1: int, h2: int, out_features: int
):
# Use for these builders for buliding a neuron
# In this case, tehre is no wait fou
AndNeruon = BuildAnd().no_wf().inter_on().prob_union()
OrNeuron = BuildOr().no_wf().union_on().prob_inter()
#
self.fuzzifier = mistify.fuzzify.SigmoidFuzzifier.from_linspace(
n_terms, 'min_core', 'average'
)
self.flatten = FlattenCat()
self.layer1 = OrNeuron(in_features * categories, h1)
self.layer2 = AndNeruon(h1, h2)
self.layer3 = OrNeuron(h2, out_features * out_categories)
self.deflatten = DeflattenCat(out_categories)
self.defuzzifier = mistify.fuzzify.IsoscelesFuzzyConverter.from_linspace(
out_terms, 'min_core', 'average'
)
def forward(self, x: torch.Tensor) -> torch.Tensor:
m = self.fuzzifier(x)
m = self.flatten(m)
m = self.layer1(m)
m = self.layer2(m)
m = self.layer3(m)
# use to prepare for defuzzification
m = self.deflatten(m)
return self.defuzzifier.defuzzify(m)
```
Since it uses Torch, these fuzzy systems can easily be stacked.
## Contributing
To contribute to the project
1. Fork the project
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Open a pull request
## License
This project is licensed under the MIT License - see the LICENSE.md file for details.
## Citing this Software
If you use this software in your research, we request you cite it. We have provided a `CITATION.cff` file in the root of the repository. Here is an example of how you might use it in BibTeX:
Raw data
{
"_id": null,
"home_page": "https://github.com/short-greg/mistify",
"name": "mistify",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Greg Short",
"author_email": "g.short@kurenai.waseda.jp",
"download_url": "https://files.pythonhosted.org/packages/31/43/79a56885b457d7274e8aed910f14cd303da05f55f7f0a619351231cb3820/mistify-0.0.1.tar.gz",
"platform": null,
"description": "# Mistify\n\nMistify is a library built on PyTorch for building Neurofuzzy Systems. A neurofuzzy system is a trainable fuzzy system, typically consisting of a fuzzifier, rules layers, and a defuzzifier. Mistify provides a variety of modules to use at each layer of the pipeline \n\n## Installation\n\n```bash\npip install mistify\n```\n\n## Brief Overview\n\nMistify consists of subpackages for inference operations, fuzzification and defuzzification, and preprocessing and postprocessing. It incldes \n\n- **mistify**: The core functions used for fuzzification and inference.\n- **mistify.fuzzify**: Modules for building fuzzifiers and defuzzifiers. Has a variety of shapes or other fuzzification and defuzzification modules to use.\n- **mistify.infer**: Modules for performing inference operations such as Or Neurons, Intersections, Activations etc.\n- **mistify.process**: Modules for preprocessing or postprocessing on the data to input into the fuzzy system\n- **mistify.systems**: Modules for building systems more easily.\n- **mistify.utils**: Utilities used by other modules in Mistify. \n\n## Usage\n\nMistify's primary prupose is to build neurofuzzy systems or fuzzy neural networks using the the framework of PyTorch. \n\nHere is a (non-working) example that uses alternating Or and And neurons.\n```bash\n\nclass FuzzySystem(nn.Module):\n\n def __init__(\n self, in_features: int, h1: int, h2: int, out_features: int\n ):\n\n # Use for these builders for buliding a neuron\n # In this case, tehre is no wait fou\n AndNeruon = BuildAnd().no_wf().inter_on().prob_union()\n OrNeuron = BuildOr().no_wf().union_on().prob_inter()\n\n # \n self.fuzzifier = mistify.fuzzify.SigmoidFuzzifier.from_linspace(\n n_terms, 'min_core', 'average'\n )\n self.flatten = FlattenCat()\n self.layer1 = OrNeuron(in_features * categories, h1)\n self.layer2 = AndNeruon(h1, h2)\n self.layer3 = OrNeuron(h2, out_features * out_categories)\n self.deflatten = DeflattenCat(out_categories)\n\n self.defuzzifier = mistify.fuzzify.IsoscelesFuzzyConverter.from_linspace(\n out_terms, 'min_core', 'average'\n )\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n\n m = self.fuzzifier(x)\n m = self.flatten(m)\n m = self.layer1(m)\n m = self.layer2(m)\n m = self.layer3(m)\n # use to prepare for defuzzification\n m = self.deflatten(m)\n return self.defuzzifier.defuzzify(m)\n\n```\n\nSince it uses Torch, these fuzzy systems can easily be stacked. \n\n\n## Contributing\n\nTo contribute to the project\n\n1. Fork the project\n2. Create your feature branch\n3. Commit your changes\n4. Push to the branch\n5. Open a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE.md file for details.\n\n## Citing this Software\n\nIf you use this software in your research, we request you cite it. We have provided a `CITATION.cff` file in the root of the repository. Here is an example of how you might use it in BibTeX:\n\n",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "Neuro-fuzzy systems with PyTorch.",
"version": "0.0.1",
"project_urls": {
"Documentation": "https://mistify.readthedocs.com",
"Homepage": "https://github.com/short-greg/mistify",
"Repository": "https://github.com/short-greg/mistify"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2606e85e9cc86818fdb7c78f1f01d5615db5c10aa59215491a7b15e9211bd3db",
"md5": "675591e78ac3dfe5c88847d3b0ac3305",
"sha256": "2f20c02aac7cad8202422d0e3fd2948c71cf2a41833648fdcc79eaba1c97ce97"
},
"downloads": -1,
"filename": "mistify-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "675591e78ac3dfe5c88847d3b0ac3305",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 71996,
"upload_time": "2024-07-25T01:42:08",
"upload_time_iso_8601": "2024-07-25T01:42:08.725827Z",
"url": "https://files.pythonhosted.org/packages/26/06/e85e9cc86818fdb7c78f1f01d5615db5c10aa59215491a7b15e9211bd3db/mistify-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "314379a56885b457d7274e8aed910f14cd303da05f55f7f0a619351231cb3820",
"md5": "6b9a0dd564932415cf08563e4e1a92e0",
"sha256": "b8e636eecce4811f87717fac54ece4b665ca5a3a1ca4ce26f50d8ed874878d14"
},
"downloads": -1,
"filename": "mistify-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6b9a0dd564932415cf08563e4e1a92e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 50347,
"upload_time": "2024-07-25T01:42:10",
"upload_time_iso_8601": "2024-07-25T01:42:10.975365Z",
"url": "https://files.pythonhosted.org/packages/31/43/79a56885b457d7274e8aed910f14cd303da05f55f7f0a619351231cb3820/mistify-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-25 01:42:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "short-greg",
"github_project": "mistify",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mistify"
}