pycascor


Namepycascor JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryCascade Correlation Network Simulator
upload_time2024-03-31 19:10:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Caroline Simpson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cascade correlation neural network cascor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyCasCor

## Description
A python implementation of a Cascade Correlation Network Simulator

## Installation

### Easiest Option - Install from PyPi

`pip install pycascor`

### Using the source repository

1. Clone the repository locally
   1. `git clone --recurse-submodules https://gitlab.com/cpsimpson/cascade-correlation-network-simulator.git`
      1. If you clone without the `--recurse-submodules` the proben1 repository will not be cloned. You can pull this file after cloning with the following commands `git submodule init` and `git submodule update`.
2. Create and activate virtual environment
   1. `python -m venv venv`
   2. `. venv/bin/activate`
3. Install dependencies
   1. `pip install .`

## Usage

Example of Training on XOR

### Cascade Correlation Network

```python
from pycascor.network import CCNetwork
from pycascor.activation_functions import Sigmoid
from pycascor.trainer import Trainer

xor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]
xor_targets = [[-0.5], [0.5], [0.5], [-0.5]]
      
trainer = Trainer([(8, Sigmoid())])
net = CCNetwork(2, 1, Sigmoid())

net = trainer.train_network(xor_inputs, xor_targets, net)

for x in xor_inputs:
    net.full_forward_pass(x)

output_values = [node.value for node in net.output_nodes]
```

### Small Magnitude Weight Pruning
```python
from pycascor.network import PrunableCCNetwork
from pycascor.activation_functions import Sigmoid
from pycascor.trainer import PruneTrainer

xor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]
xor_targets = [[-0.5], [0.5], [0.5], [-0.5]]
      
trainer = PruneTrainer([(8, Sigmoid())])
net = PrunableCCNetwork(2, 1, Sigmoid())

net = trainer.train_network(xor_inputs, xor_targets, net)

for x in xor_inputs:
    net.full_forward_pass(x)

output_values = [node.value for node in net.output_nodes]
```

### Optimal Brain Damage Pruning
```python
from pycascor.network import PrunableCCNetwork
from pycascor.activation_functions import Sigmoid
from pycascor.trainer import OptimalBrainDamageTrainer

xor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]
xor_targets = [[-0.5], [0.5], [0.5], [-0.5]]
      
trainer = OptimalBrainDamageTrainer([(8, Sigmoid())])
net = PrunableCCNetwork(2, 1, Sigmoid())

net = trainer.train_network(xor_inputs, xor_targets, net)

for x in xor_inputs:
    net.full_forward_pass(x)

output_values = [node.value for node in net.output_nodes]
```

## Simulator Examples
In addition to the library code `pycascor`, you will find an `examples` directory this repository. 
This contains a simulator script `simulation.py` which is able to run multiple trials of various 
datasets across the 3 versions of the network training algorithms. This includes some data which comes 
from the Proben1 benchmarking dataset project originally compiled by Lutz Prechelt. A copy of the data
is linked as a submodule.

```bash
. venv/bin/activate
pip install .
python examples/simulation.py <example> <number-of-trials>
```
Example options: spirals, cancer, glass, xor

Various output files will be written to a `result` folder for your analysis.

spirals trains the networks on a subset of the [two-spirals classification problem](https://www.researchgate.net/publication/269337640_Learning_to_Tell_Two_Spirals_Apart). 
The resulting networks are then validated and tested on the remaining points

cancer trains the networks on the 
["Wisconsin breast cancer database"](https://github.com/cpsimpson/proben1/tree/master/cancer) from the UCI 
machine learning dataset included in the [Proben1](https://github.com/cpsimpson/proben1) repository.

glass trains the networks on the ["glass"](https://github.com/cpsimpson/proben1/tree/master/glass) from the UCI 
machine learning dataset included in the [Proben1](https://github.com/cpsimpson/proben1) repository.

xor trains and tests the networks on the XOR dataset.

## Support
Feel free to create an Issue or MR if you find a bug or want to add a contribution.

## Contributing

### Running Tests
To run the tests you can run `pytest` from the project root directory.


## Authors and acknowledgment
This implementation is based on the code of Scott Fahlman and Thomas Shultz. 
Thanks to Dr. Britt Anderson, Hanbin Go, James Houle, Julia Schirmeister, 
Vivian DiBerardino, and Ciaran Neely for contributing to my understanding 
of the algorithm and inspiring this project.

## License
This code and related materials is made available under the MIT License. 

## Project status
This is a project that I created for a directed studies course at while studying at University of Waterloo.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pycascor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Caroline Simpson <pycascor@hoojiboo.com>",
    "keywords": "Cascade Correlation, neural network, cascor",
    "author": null,
    "author_email": "Caroline Simpson <pycascor@hoojiboo.com>",
    "download_url": "https://files.pythonhosted.org/packages/bf/c1/408d64bb7941a01c351334890a005ca80b8c1ec779946e19dd9fe6ab5bc4/pycascor-0.1.2.tar.gz",
    "platform": null,
    "description": "# PyCasCor\n\n## Description\nA python implementation of a Cascade Correlation Network Simulator\n\n## Installation\n\n### Easiest Option - Install from PyPi\n\n`pip install pycascor`\n\n### Using the source repository\n\n1. Clone the repository locally\n   1. `git clone --recurse-submodules https://gitlab.com/cpsimpson/cascade-correlation-network-simulator.git`\n      1. If you clone without the `--recurse-submodules` the proben1 repository will not be cloned. You can pull this file after cloning with the following commands `git submodule init` and `git submodule update`.\n2. Create and activate virtual environment\n   1. `python -m venv venv`\n   2. `. venv/bin/activate`\n3. Install dependencies\n   1. `pip install .`\n\n## Usage\n\nExample of Training on XOR\n\n### Cascade Correlation Network\n\n```python\nfrom pycascor.network import CCNetwork\nfrom pycascor.activation_functions import Sigmoid\nfrom pycascor.trainer import Trainer\n\nxor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]\nxor_targets = [[-0.5], [0.5], [0.5], [-0.5]]\n      \ntrainer = Trainer([(8, Sigmoid())])\nnet = CCNetwork(2, 1, Sigmoid())\n\nnet = trainer.train_network(xor_inputs, xor_targets, net)\n\nfor x in xor_inputs:\n    net.full_forward_pass(x)\n\noutput_values = [node.value for node in net.output_nodes]\n```\n\n### Small Magnitude Weight Pruning\n```python\nfrom pycascor.network import PrunableCCNetwork\nfrom pycascor.activation_functions import Sigmoid\nfrom pycascor.trainer import PruneTrainer\n\nxor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]\nxor_targets = [[-0.5], [0.5], [0.5], [-0.5]]\n      \ntrainer = PruneTrainer([(8, Sigmoid())])\nnet = PrunableCCNetwork(2, 1, Sigmoid())\n\nnet = trainer.train_network(xor_inputs, xor_targets, net)\n\nfor x in xor_inputs:\n    net.full_forward_pass(x)\n\noutput_values = [node.value for node in net.output_nodes]\n```\n\n### Optimal Brain Damage Pruning\n```python\nfrom pycascor.network import PrunableCCNetwork\nfrom pycascor.activation_functions import Sigmoid\nfrom pycascor.trainer import OptimalBrainDamageTrainer\n\nxor_inputs = [[0, 0], [0, 1], [1, 0], [1, 1]]\nxor_targets = [[-0.5], [0.5], [0.5], [-0.5]]\n      \ntrainer = OptimalBrainDamageTrainer([(8, Sigmoid())])\nnet = PrunableCCNetwork(2, 1, Sigmoid())\n\nnet = trainer.train_network(xor_inputs, xor_targets, net)\n\nfor x in xor_inputs:\n    net.full_forward_pass(x)\n\noutput_values = [node.value for node in net.output_nodes]\n```\n\n## Simulator Examples\nIn addition to the library code `pycascor`, you will find an `examples` directory this repository. \nThis contains a simulator script `simulation.py` which is able to run multiple trials of various \ndatasets across the 3 versions of the network training algorithms. This includes some data which comes \nfrom the Proben1 benchmarking dataset project originally compiled by Lutz Prechelt. A copy of the data\nis linked as a submodule.\n\n```bash\n. venv/bin/activate\npip install .\npython examples/simulation.py <example> <number-of-trials>\n```\nExample options: spirals, cancer, glass, xor\n\nVarious output files will be written to a `result` folder for your analysis.\n\nspirals trains the networks on a subset of the [two-spirals classification problem](https://www.researchgate.net/publication/269337640_Learning_to_Tell_Two_Spirals_Apart). \nThe resulting networks are then validated and tested on the remaining points\n\ncancer trains the networks on the \n[\"Wisconsin breast cancer database\"](https://github.com/cpsimpson/proben1/tree/master/cancer) from the UCI \nmachine learning dataset included in the [Proben1](https://github.com/cpsimpson/proben1) repository.\n\nglass trains the networks on the [\"glass\"](https://github.com/cpsimpson/proben1/tree/master/glass) from the UCI \nmachine learning dataset included in the [Proben1](https://github.com/cpsimpson/proben1) repository.\n\nxor trains and tests the networks on the XOR dataset.\n\n## Support\nFeel free to create an Issue or MR if you find a bug or want to add a contribution.\n\n## Contributing\n\n### Running Tests\nTo run the tests you can run `pytest` from the project root directory.\n\n\n## Authors and acknowledgment\nThis implementation is based on the code of Scott Fahlman and Thomas Shultz. \nThanks to Dr. Britt Anderson, Hanbin Go, James Houle, Julia Schirmeister, \nVivian DiBerardino, and Ciaran Neely for contributing to my understanding \nof the algorithm and inspiring this project.\n\n## License\nThis code and related materials is made available under the MIT License. \n\n## Project status\nThis is a project that I created for a directed studies course at while studying at University of Waterloo.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Caroline Simpson  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Cascade Correlation Network Simulator",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://gitlab.com/cpsimpson/cascade-correlation-network-simulator/-/issues",
        "Repository": "https://gitlab.com/cpsimpson/cascade-correlation-network-simulator"
    },
    "split_keywords": [
        "cascade correlation",
        " neural network",
        " cascor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cb4611b6bd249c16ccffe169b151f1b525317a9466031fd7b3d68adc7fdd827",
                "md5": "b3b95fd53fdf3d25113e108783a3e26d",
                "sha256": "b94df4c2bd264d2a87ae6e7c018341908dfa50c5aecc95dc95e5bcd0a7d3f7bc"
            },
            "downloads": -1,
            "filename": "pycascor-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b3b95fd53fdf3d25113e108783a3e26d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15628,
            "upload_time": "2024-03-31T19:10:46",
            "upload_time_iso_8601": "2024-03-31T19:10:46.123861Z",
            "url": "https://files.pythonhosted.org/packages/4c/b4/611b6bd249c16ccffe169b151f1b525317a9466031fd7b3d68adc7fdd827/pycascor-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfc1408d64bb7941a01c351334890a005ca80b8c1ec779946e19dd9fe6ab5bc4",
                "md5": "bed1a704cad093e4f6b93c71d0e2c48d",
                "sha256": "f84382718809f7cdc17e009771ce0825fcad9172836e4bf2cc328635d4ff1ca7"
            },
            "downloads": -1,
            "filename": "pycascor-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "bed1a704cad093e4f6b93c71d0e2c48d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16125,
            "upload_time": "2024-03-31T19:10:47",
            "upload_time_iso_8601": "2024-03-31T19:10:47.747187Z",
            "url": "https://files.pythonhosted.org/packages/bf/c1/408d64bb7941a01c351334890a005ca80b8c1ec779946e19dd9fe6ab5bc4/pycascor-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-31 19:10:47",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "cpsimpson",
    "gitlab_project": "cascade-correlation-network-simulator",
    "lcname": "pycascor"
}
        
Elapsed time: 0.21409s