Popularity
6.1
Growing
Activity
0.0
-
23
3
4

Programming language: Crystal
License: MIT License
Tags: Machine Learning    
Latest version: v0.1.13

ai4cr alternatives and similar shards

Based on the "Machine Learning" category.
Alternatively, view ai4cr alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of ai4cr or a related project?

Add another 'Machine Learning' Shard

README

ai4cr

CircleCI status: CircleCI

GitHub release

Artificial Intelligence for Crystal (based on https://github.com/SergioFierens/ai4r)

Installation

Add this to your application's shard.yml:

dependencies:
  ai4cr:
    github: drhuffman12/ai4cr
    branch: master

Usage

require "ai4cr"

So far, only Ai4cr::NeuralNetwork::Backpropagation and related tests have been ported.

NOTE: marshal_dump and marshal_load from ai4r have been replaced by to_json and from_json instead, e.g.:

# Create and save a net
net = Ai4cr::NeuralNetwork::Backpropagation.new(...)
File.write("../ai4cr_ui/db/seeds/BackpropagationNet.new.json",net.to_json)

# Train and save a net
net.train(some_input, expected_output)
File.write("../ai4cr_ui/db/seeds/BackpropagationNet.trained.json",net.to_json)

# Verify serialization in a spec
json = net.to_json
net2 = Ai4cr::NeuralNetwork::Backpropagation.from_json(json)
assert_approximate_equality_of_nested_list net.weights, net2.weights, 0.000000001

Comparison benchmarks

To build and run them:

crystal build --release  src/bench/mini_nets_vs_backprop.cr
./mini_nets_vs_backprop

Example output:

[docs/mini_nets_vs_backprop.example.png](docs/mini_nets_vs_backprop.example.png)

To dig deeper into performance refinement:

crystal build --release src/mini_nets_vs_backprop
mkdir -p tmp/
valgrind --tool=callgrind --cache-sim=yes --branch-sim=yes --callgrind-out-file=tmp/mini_nets_vs_backprop.out ./mini_nets_vs_backprop

Roadmap

  • [x] Generate an error history plot using AsciiBarCharter and error_distance_history , e.g.:

    plot: '▇▊▂_▅▅▅_▅_▅▅▅▅_▅▅__▅_▅____▅___'
    

    (Run crystal spec spec_examples to see more error history plot examples. NOTE: These run short training sessions, so some tests are likely to fail some of the time.)

  • [ ] Add Cmn ("Connectable Mini Networks") (WIP)

    • [x] simple benchmark comparisons
    • [x] Learning Styles
    • [x] Pelu
    • [x] Relu
    • [x] Sigmoid
    • [x] Tanh
    • [x] MiniNet
    • [x] Common modules
    • [x] JSON importable/exportable
    • [x] can use various 'Learning Styles'
    • [ ] (?) move 'Learning Styles'-specific methods from MiniNet into Enum
    • [ ] misc Connected Net Sets (WIP)
    • [x] Chain
    • [ ] RNN
    • [ ] (TBD)
    • [ ] ...
    • [ ] (TBD)
    • [ ] ...
  • [ ] Add RNN

  • [ ] Port from ai4r:

    • [ ] classifiers
    • [ ] classifier.rb
    • [ ] hyperpipes.rb
    • [ ] ib1.rb
    • [ ] id3.rb
    • [ ] multilayer_perceptron.rb
    • [ ] naive_bayes.rb
    • [ ] one_r.rb
    • [ ] prism.rb
    • [ ] simple_linear_regression.rb
    • [ ] votes.rb
      • [ ] zero_r.rb
    • [ ] clusterers
    • [ ] average_linkage.rb
    • [ ] bisecting_k_means.rb
    • [ ] centroid_linkage.rb
    • [ ] clusterer.rb
    • [ ] complete_linkage.rb
    • [ ] diana.rb
    • [ ] k_means.rb
    • [ ] median_linkage.rb
    • [ ] single_linkage.rb
    • [ ] ward_linkage_hierarchical.rb
    • [ ] ward_linkage.rb
      • [ ] weighted_average_linkage.rb
    • [ ] data
    • [ ] data_set.rb
    • [ ] parameterizable.rb
    • [ ] proximity.rb
      • [ ] statistics.rb
    • [ ] experiment
      • [ ] classifier_evaluator.rb
    • [ ] genetic_algorithm
      • [ ] genetic_algorithm.rb
    • [ ] neural_network
    • [x] backpropagation.rb
    • [ ] hopfield.rb
    • [ ] som
    • [ ] layer.rb
    • [ ] node.rb
    • [ ] som.rb
    • [ ] two_phase_layer.rb

If you'd like another class of Ai4r ported, feel free to submit a new issue.

Contributing

  1. Fork it ( https://github.com/drhuffman12/ai4cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

(Re-)Format

docker-compose run app scripts/reformat

Build

# for a cleaner build:
docker-compose build --force-rm --no-cache --pull

# normally:
docker-compose build

Show version

docker-compose run app scripts/version_info

Test

docker-compose run app crystal spec

Docker console

docker-compose run app /bin/bash

ICR console

icr -r ./src/ai4cr

See also

Contributors

Example Spec Results (running on a Lenovo Ideapad y700 w/ i7-6700HQ)

I included the triangle-square-cross training example as test cases.

As expected, the net sometimes correctly guesses all of the examples, more or less, depending on how many times it is trained and various other (random) factors.

Below is an example of the net successfully recognizing all nine test cases.

Setup

$ cd $MY_DEV_FOLDER

$ git clone https://github.com/drhuffman12/ai4cr.git

$ cd ai4cr

$ docker-compose build

These should NEVER fail!

For any tests that should NEVER fail (e.g.: in spite of sufficient training), put them into spec, and run them via:

$ docker-compose run app scripts/test_always
..............................

Finished in 4.01 milliseconds
30 examples, 0 failures, 0 errors, 0 pending
Execute: 00:00:00.010855717

These will probably SOMETIMES fail!

For any tests that could fails sometimes (e.g.: if not trained enough), put them into spec_examples, and run them via:

$ docker-compose run app scripts/test_sometimes
.............

Finished in 6.76 seconds
16 examples, 0 failures, 0 errors, 0 pending
Execute: 00:00:06.769663359

NOTE: That time, it took less than a second to build. I did notice that it took about 10 seconds to build the first run and only less than a second each successive run.