GithubHelp home page GithubHelp logo

jameszhuh / markovnetwork Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rhiever/markovnetwork

0.0 2.0 0.0 41 KB

Python implementation of Markov Networks for neural computing.

License: MIT License

Python 89.66% Shell 10.34%

markovnetwork's Introduction

Build Status Code Health Coverage Status Python 2.7 Python 3.5 License PyPI version

Markov Network

Join the chat at https://gitter.im/rhiever/MarkovNetwork

Python implementation of Markov Networks for neural computing.

License

Please see the repository license for the licensing and usage information for datacleaner.

Generally, we have licensed the MarkovNetwork package to make it as widely usable as possible.

Installation

MarkovNetwork is built to use NumPy arrays for fast array processing. As such, we recommend installing the Anaconda Python distribution prior to installing MarkovNetwork. However, MarkovNetwork should work fine with any basic install of Python.

Once the prerequisites are installed, datacleaner can be installed with a simple pip command:

pip install MarkovNetwork

Usage

When creating an instance of a MarkovNetwork, you can pass the following parameters:

num_input_states: int (required)
    The number of input states in the Markov Network
num_memory_states: int (required)
    The number of internal memory states in the Markov Network
num_output_states: int (required)
    The number of output states in the Markov Network
seed_num_markov_gates: int (default: 4)
    The number of Markov Gates with which to seed the Markov Network
    It is important to ensure that randomly-generated Markov Networks have at least a few Markov Gates to begin with
    May sometimes result in fewer Markov Gates if the Markov Gates are randomly seeded in the same location
probabilistic: bool (default: True)
    Flag indicating whether the Markov Gates are probabilistic or deterministic
genome: array-like (default=None)
    An array representation of the Markov Network to construct
    All values in the array must be integers in the range [0, 255]
    If None, then a random Markov Network will be generated

The following code creatives a deterministic MarkovNetwork, provides some input, activates the network, then retrieves the output:

from MarkovNetwork import MarkovNetwork
import numpy as np

my_mn = MarkovNetwork(num_input_states=2,
                      num_memory_states=4,
                      num_output_states=2,
                      seed_num_markov_gates=5,
                      probabilistic=False)

my_mn.update_input_states([1, 0])
my_mn.activate_network()
output_states = my_mn.get_output_states()

You can repeat this process multiple times with different input:

from MarkovNetwork import MarkovNetwork
import numpy as np

my_mn = MarkovNetwork(num_input_states=2,
                      num_memory_states=4,
                      num_output_states=2,
                      seed_num_markov_gates=5,
                      probabilistic=False)

my_mn.update_input_states([1, 0])
my_mn.activate_network()
output_states1 = my_mn.get_output_states()

my_mn.update_input_states([0, 1])
my_mn.activate_network()
output_states2 = my_mn.get_output_states()

If you want to allow the MarkovNetwork to activate multiple times with the same inputs, you can pass a num_activations parameter to activate_network():

from MarkovNetwork import MarkovNetwork
import numpy as np

my_mn = MarkovNetwork(num_input_states=2,
                      num_memory_states=4,
                      num_output_states=2,
                      seed_num_markov_gates=5,
                      probabilistic=False)

my_mn.update_input_states([1, 0])
my_mn.activate_network(num_activations=20)
output_states = my_mn.get_output_states()

Finally, you can seed a MarkovNetwork with a pre-existing byte string by passing the genome parameter:

from MarkovNetwork import MarkovNetwork
import numpy as np

my_mn_genome = np.random.randint(0, 256, 15000)
my_mn = MarkovNetwork(num_input_states=2,
                      num_memory_states=4,
                      num_output_states=2,
                      probabilistic=False,
                      genome=my_mn_genome)

Having problems with the MarkovNetwork package?

Before you file a bug report, please check the existing issues to make sure that your issue hasn't already been filed or solved. If the bug is unreported, please file a new issue and describe your bug in detail.

Contributing to the MarkovNetwork package

We welcome you to check the existing issues for bugs or enhancements to work on. If you have an idea for an extension to the MarkovNetwork package, please file a new issue so we can discuss it.

Citing MarkovNetwork

If you use the MarkovNetwork package as part of your workflow in a scientific publication, please consider citing the following publication that describes Markov Networks in detail.

Randal S. Olson, David B. Knoester, and Christoph Adami. "Evolution of swarming behavior is shaped by how predators attack." Artificial Life Journal, to appear in Spring 2016.

@misc{Olson2016SelfishHerd,
author = {Olson, Randal S. and Knoester, David B. and Adami, Christoph},
title = {Evolution of swarming behavior is shaped by how predators attack},
howpublished={arXiv e-print. http://arxiv.org/abs/1310.6012},
year={2016}
}

You can also cite the repository directly using the following DOI:

DOI

markovnetwork's People

Contributors

rhiever avatar gitter-badger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.