Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vivi-coding/aima-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ba301e7
Choose a base ref
...
head repository: aimacode/aima-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 61d695b
Choose a head ref
Loading
Showing with 86,119 additions and 11,027 deletions.
  1. +3 −0 .coveragerc
  2. +6 −0 .gitignore
  3. +7 −7 .travis.yml
  4. +35 −40 CONTRIBUTING.md
  5. +166 −117 README.md
  6. +11 −0 SUBMODULE.md
  7. +227 −776 agents.ipynb
  8. +236 −137 agents.py
  9. +1,089 −0 agents4e.py
  10. +1 −1 aima-data
  11. +1,999 −0 arc_consistency_heuristics.ipynb
  12. +0 −528 canvas.py
  13. +2,402 −0 classical_planning_approaches.ipynb
  14. +2,214 −317 csp.ipynb
  15. +795 −90 csp.py
  16. +584 −0 deep_learning4e.py
  17. +177 −958 games.ipynb
  18. +289 −43 games.py
  19. +1,667 −0 games4e.ipynb
  20. +635 −0 games4e.py
  21. +151 −0 gui/eight_puzzle.py
  22. +189 −0 gui/genetic_algorithm_example.py
  23. +676 −0 gui/grid_mdp.py
  24. +672 −0 gui/romania_problem.py
  25. +232 −0 gui/tic-tac-toe.py
  26. +342 −0 gui/tsp.py
  27. +154 −0 gui/vacuum_agent.py
  28. +191 −0 gui/xy_vacuum_environment.py
  29. BIN images/-0.04.jpg
  30. BIN images/-0.4.jpg
  31. BIN images/-4.jpg
  32. BIN images/4.jpg
  33. BIN images/broxrevised.png
  34. BIN images/cake_graph.jpg
  35. BIN images/decisiontree_fruit.jpg
  36. BIN images/ensemble_learner.jpg
  37. BIN images/ge0.jpg
  38. BIN images/ge1.jpg
  39. BIN images/ge2.jpg
  40. BIN images/ge4.jpg
  41. BIN images/general_learning_agent.jpg
  42. BIN images/grid_mdp.jpg
  43. BIN images/grid_mdp_agent.jpg
  44. BIN images/hillclimb-tsp.png
  45. BIN images/knowledge_FOIL_grandparent.png
  46. BIN images/knowledge_foil_family.png
  47. BIN images/maze.png
  48. BIN images/mdp-b.png
  49. BIN images/mdp-c.png
  50. BIN images/mdp-d.png
  51. BIN images/model_based_reflex_agent.jpg
  52. BIN images/model_goal_based_agent.jpg
  53. BIN images/model_utility_based_agent.jpg
  54. BIN images/multilayer_perceptron.png
  55. BIN images/neural_net.png
  56. BIN images/parse_tree.png
  57. BIN images/pop.jpg
  58. BIN images/queen_s.png
  59. BIN images/random_forest.png
  60. BIN images/refinement.png
  61. BIN images/restaurant.png
  62. BIN images/romania_map.png
  63. BIN images/simple_problem_solving_agent.jpg
  64. BIN images/simple_reflex_agent.jpg
  65. BIN images/stapler1-test.png
  66. +2,539 −0 improving_sat_algorithms.ipynb
  67. +1 −1 index.ipynb
  68. +35 −42 intro.ipynb
  69. +0 −1 ipyviews.py
  70. +422 −0 knowledge.py
  71. +639 −0 knowledge_FOIL.ipynb
  72. +662 −0 knowledge_current_best.ipynb
  73. +1,088 −0 knowledge_version_space.ipynb
  74. +751 −459 learning.ipynb
  75. +724 −580 learning.py
  76. +1,039 −0 learning4e.py
  77. +988 −0 learning_apps.ipynb
  78. +4,421 −133 logic.ipynb
  79. +1,232 −183 logic.py
  80. +1,665 −0 logic4e.py
  81. +168 −0 making_simple_decision4e.py
  82. +2,630 −127 mdp.ipynb
  83. +338 −40 mdp.py
  84. +516 −0 mdp4e.py
  85. +1,825 −0 mdp_apps.ipynb
  86. +570 −0 neural_nets.ipynb
  87. +1,002 −5 nlp.ipynb
  88. +226 −61 nlp.py
  89. +523 −0 nlp4e.py
  90. +1,038 −0 nlp_apps.ipynb
  91. +1,122 −0 notebook.py
  92. +1,158 −0 notebook4e.py
  93. +508 −0 notebooks/chapter19/Learners.ipynb
  94. +398 −0 notebooks/chapter19/Loss Functions and Layers.ipynb
  95. +311 −0 notebooks/chapter19/Optimizer and Backpropagation.ipynb
  96. +487 −0 notebooks/chapter19/RNN.ipynb
  97. BIN notebooks/chapter19/images/autoencoder.png
  98. BIN notebooks/chapter19/images/backprop.png
  99. BIN notebooks/chapter19/images/corss_entropy_plot.png
  100. BIN notebooks/chapter19/images/mse_plot.png
  101. BIN notebooks/chapter19/images/nn.png
  102. BIN notebooks/chapter19/images/nn_steps.png
  103. BIN notebooks/chapter19/images/perceptron.png
  104. BIN notebooks/chapter19/images/rnn_connections.png
  105. BIN notebooks/chapter19/images/rnn_unit.png
  106. BIN notebooks/chapter19/images/rnn_units.png
  107. BIN notebooks/chapter19/images/vanilla.png
  108. +212 −0 notebooks/chapter21/Active Reinforcement Learning.ipynb
  109. +424 −0 notebooks/chapter21/Passive Reinforcement Learning.ipynb
  110. BIN notebooks/chapter21/images/mdp.png
  111. +526 −0 notebooks/chapter22/Grammar.ipynb
  112. +92 −0 notebooks/chapter22/Introduction.ipynb
  113. +522 −0 notebooks/chapter22/Parsing.ipynb
  114. BIN notebooks/chapter22/images/parse_tree.png
  115. +1,038 −0 notebooks/chapter22/nlp_apps.ipynb
  116. +408 −0 notebooks/chapter24/Image Edge Detection.ipynb
  117. +480 −0 notebooks/chapter24/Image Segmentation.ipynb
  118. +454 −0 notebooks/chapter24/Objects in Images.ipynb
  119. BIN notebooks/chapter24/images/RCNN.png
  120. BIN notebooks/chapter24/images/derivative_of_gaussian.png
  121. BIN notebooks/chapter24/images/gradients.png
  122. BIN notebooks/chapter24/images/laplacian.png
  123. BIN notebooks/chapter24/images/laplacian_kernels.png
  124. BIN notebooks/chapter24/images/stapler.png
  125. BIN notebooks/chapter24/images/stapler_bbox.png
  126. +3,835 −0 obsolete_search4e.ipynb
  127. +467 −0 perception4e.py
  128. +3,626 −113 planning.ipynb
  129. +1,644 −498 planning.py
  130. +638 −0 planning_angelic_search.ipynb
  131. +1,066 −0 planning_graphPlan.ipynb
  132. +546 −0 planning_hierarchical_search.ipynb
  133. +850 −0 planning_partial_order_planner.ipynb
  134. +341 −0 planning_total_order_planner.ipynb
  135. +154 −0 probabilistic_learning.py
  136. +5,653 −369 probability.ipynb
  137. +306 −87 probability.py
  138. 0 probability-4e.ipynb → probability4e.ipynb
  139. +776 −0 probability4e.py
  140. +3 −1 pytest.ini
  141. +644 −0 reinforcement_learning.ipynb
  142. +337 −0 reinforcement_learning.py
  143. +353 −0 reinforcement_learning4e.py
  144. +17 −1 requirements.txt
  145. +0 −552 rl.ipynb
  146. +0 −203 rl.py
  147. +0 −2,151 search-4e.ipynb
  148. +5,758 −1,050 search.ipynb
  149. +487 −194 search.py
  150. +2,652 −0 search4e.ipynb
  151. +320 −7 tests/test_agents.py
  152. +386 −0 tests/test_agents4e.py
  153. +347 −49 tests/test_csp.py
  154. +80 −0 tests/test_deep_learning4e.py
  155. +27 −20 tests/test_games.py
  156. +96 −0 tests/test_games4e.py
  157. +285 −0 tests/test_knowledge.py
  158. +101 −107 tests/test_learning.py
  159. +127 −0 tests/test_learning4e.py
  160. +159 −95 tests/test_logic.py
  161. +359 −0 tests/test_logic4e.py
  162. +138 −11 tests/test_mdp.py
  163. +176 −0 tests/test_mdp4e.py
  164. +126 −18 tests/test_nlp.py
  165. +139 −0 tests/test_nlp4e.py
  166. +87 −0 tests/test_perception4e.py
  167. +692 −65 tests/test_planning.py
  168. +38 −0 tests/test_probabilistic_learning.py
  169. +256 −27 tests/test_probability.py
  170. +349 −0 tests/test_probability4e.py
  171. +71 −0 tests/test_reinforcement_learning.py
  172. +69 −0 tests/test_reinforcement_learning4e.py
  173. +0 −55 tests/test_rl.py
  174. +226 −25 tests/test_search.py
  175. +80 −97 tests/test_text.py
  176. +153 −141 tests/test_utils.py
  177. +465 −133 text.ipynb
  178. +88 −75 text.py
  179. +268 −237 utils.py
  180. +807 −0 utils4e.py
  181. +701 −0 vacuum_world.ipynb
  182. +418 −0 viterbi_algorithm.ipynb
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[report]
omit =
tests/*
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
*.pytest_cache

# Translations
*.mo
@@ -70,3 +71,8 @@ target/

# dotenv
.env
.idea

# for macOS
.DS_Store
._.DS_Store
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
language:
- python
language: python

python:
- "3.4"
- 3.5
- 3.6
- 3.7
- 3.8

before_install:
- git submodule update --remote

install:
- pip install six
- pip install flake8
- pip install ipython
- pip install --upgrade -r requirements.txt

script:
- py.test
- py.test --cov=./
- python -m doctest -v *.py

after_success:
75 changes: 35 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
How to Contribute to aima-python
==========================

Thanks for considering contributing to `aima-python`! Whether you are an aspiring [Google Summer of Code](https://summerofcode.withgoogle.com/organizations/5663121491361792/) student, or an independent contributor, here is a guide to how you can help:
Thanks for considering contributing to `aima-python`! Whether you are an aspiring [Google Summer of Code](https://summerofcode.withgoogle.com/organizations/5431334980288512/) student, or an independent contributor, here is a guide on how you can help.

First of all, you can read these write-ups from past GSoC students to get an idea about what you can do for the project. [Chipe1](https://github.com/aimacode/aima-python/issues/641) - [MrDupin](https://github.com/aimacode/aima-python/issues/632)

In general, the main ways you can contribute to the repository are the following:

1. Implement algorithms from the [list of algorithms](https://github.com/aimacode/aima-python/blob/master/README.md#index-of-algorithms).
1. Add tests for algorithms.
1. Take care of [issues](https://github.com/aimacode/aima-python/issues).
1. Write on the notebooks (`.ipynb` files).
1. Add and edit documentation (the docstrings in `.py` files).

In more detail:

## Read the Code and Start on an Issue

- First, read and understand the code to get a feel for the extent and the style.
- Look at the [issues](https://github.com/aimacode/aima-python/issues) and pick one to work on.
- One of the issues is that some algorithms are missing from the [list of algorithms](https://github.com/aimacode/aima-python/blob/master/README.md#index-of-algorithms).
- One of the issues is that some algorithms are missing from the [list of algorithms](https://github.com/aimacode/aima-python/blob/master/README.md#index-of-algorithms) and that some don't have tests.

## Port to Python 3; Pythonic Idioms; py.test
## Port to Python 3; Pythonic Idioms

- Check for common problems in [porting to Python 3](http://python3porting.com/problems.html), such as: `print` is now a function; `range` and `map` and other functions no longer produce `list`s; objects of different types can no longer be compared with `<`; strings are now Unicode; it would be nice to move `%` string formating to `.format`; there is a new `next` function for generators; integer division now returns a float; we can now use set literals.
- Check for common problems in [porting to Python 3](http://python3porting.com/problems.html), such as: `print` is now a function; `range` and `map` and other functions no longer produce `list`; objects of different types can no longer be compared with `<`; strings are now Unicode; it would be nice to move `%` string formatting to `.format`; there is a new `next` function for generators; integer division now returns a float; we can now use set literals.
- Replace old Lisp-based idioms with proper Python idioms. For example, we have many functions that were taken directly from Common Lisp, such as the `every` function: `every(callable, items)` returns true if every element of `items` is callable. This is good Lisp style, but good Python style would be to use `all` and a generator expression: `all(callable(f) for f in items)`. Eventually, fix all calls to these legacy Lisp functions and then remove the functions.
- Add more tests in `_test.py` files. Strive for terseness; it is ok to group multiple asserts into one `def test_something():` function. Move most tests to `_test.py`, but it is fine to have a single `doctest` example in the docstring of a function in the `.py` file, if the purpose of the doctest is to explain how to use the function, rather than test the implementation.

## New and Improved Algorithms

- Implement functions that were in the third edition of the book but were not yet implemented in the code. Check the [list of pseudocode algorithms (pdf)](https://github.com/aimacode/pseudocode/blob/master/aima3e-algorithms.pdf) to see what's missing.
- As we finish chapters for the new fourth edition, we will share the new pseudocode in the [`aima-pseudocode`](https://github.com/aimacode/aima-pseudocode) repository, and describe what changes are necessary.
We hope to have a `algorithm-name.md` file for each algorithm, eventually; it would be great if contributors could add some for the existing algorithms.
- Give examples of how to use the code in the `.ipynb` file.
We hope to have an `algorithm-name.md` file for each algorithm, eventually; it would be great if contributors could add some for the existing algorithms.

## Jupyter Notebooks

We still support a legacy branch, `aima3python2` (for the third edition of the textbook and for Python 2 code).
In this project we use Jupyter/IPython Notebooks to showcase the algorithms in the book. They serve as short tutorials on what the algorithms do, how they are implemented and how one can use them. To install Jupyter, you can follow the instructions [here](https://jupyter.org/install.html). These are some ways you can contribute to the notebooks:

- Proofread the notebooks for grammar mistakes, typos, or general errors.
- Move visualization and unrelated to the algorithm code from notebooks to `notebook.py` (a file used to store code for the notebooks, like visualization and other miscellaneous stuff). Make sure the notebooks still work and have their outputs showing!
- Replace the `%psource` magic notebook command with the function `psource` from `notebook.py` where needed. Examples where this is useful are a) when we want to show code for algorithm implementation and b) when we have consecutive cells with the magic keyword (in this case, if the code is large, it's best to leave the output hidden).
- Add the function `pseudocode(algorithm_name)` in algorithm sections. The function prints the pseudocode of the algorithm. You can see some example usage in [`knowledge.ipynb`](https://github.com/aimacode/aima-python/blob/master/knowledge.ipynb).
- Edit existing sections for algorithms to add more information and/or examples.
- Add visualizations for algorithms. The visualization code should go in `notebook.py` to keep things clean.
- Add new sections for algorithms not yet covered. The general format we use in the notebooks is the following: First start with an overview of the algorithm, printing the pseudocode and explaining how it works. Then, add some implementation details, including showing the code (using `psource`). Finally, add examples for the implementations, showing how the algorithms work. Don't fret with adding complex, real-world examples; the project is meant for educational purposes. You can of course choose another format if something better suits an algorithm.

Apart from the notebooks explaining how the algorithms work, we also have notebooks showcasing some indicative applications of the algorithms. These notebooks are in the `*_apps.ipynb` format. We aim to have an `apps` notebook for each module, so if you don't see one for the module you would like to contribute to, feel free to create it from scratch! In these notebooks we are looking for applications showing what the algorithms can do. The general format of these sections is this: Add a description of the problem you are trying to solve, then explain how you are going to solve it and finally provide your solution with examples. Note that any code you write should not require any external libraries apart from the ones already provided (like `matplotlib`).

# Style Guide

@@ -43,54 +65,27 @@ a one-line docstring suffices. It is rarely necessary to list what each argument
- At some point I may add [Pep 484](https://www.python.org/dev/peps/pep-0484/) type annotations, but I think I'll hold off for now;
I want to get more experience with them, and some people may still be in Python 3.4.


Contributing a Patch
====================

1. Submit an issue describing your proposed change to the repo in question (or work on an existing issue).
1. The repo owner will respond to your issue promptly.
1. Fork the desired repo, develop and test your code changes.
1. Submit a pull request.

Reporting Issues
================

- Under which versions of Python does this happen?

- Provide an example of the issue occurring.

- Is anybody working on this?

Patch Rules
===========

- Ensure that the patch is python 3.4 compliant.
- Ensure that the patch is Python 3.4 compliant.

- Include tests if your patch is supposed to solve a bug, and explain
clearly under which circumstances the bug happens. Make sure the test fails
without your patch.

- Follow the style guidelines described above.

Running the Test-Suite
=====================

The minimal requirement for running the testsuite is ``py.test``. You can
install it with:

pip install pytest

Clone this repository:

git clone https://github.com/aimacode/aima-python.git

Fetch the aima-data submodule:

cd aima-python
git submodule init
git submodule update

Then you can run the testsuite from the `aima-python` or `tests` directory with:

py.test
- Refer the issue you have fixed.
- Explain in brief what changes you have made with affected files name.

# Choice of Programming Languages

Loading