Giter Site home page Giter Site logo

aima-python's People

Contributors

darius avatar

Watchers

 avatar

aima-python's Issues

Missing Class EnvCanvas in agents.py

The current version of agents.py appears to have been truncated.

It is missing the EnvCanvas class and a set of tests for the gui environment.  
Earlier versions of the code contain these. 

Original issue reported on code.google.com by [email protected] on 23 Jul 2010 at 12:56

Can not pass the test.

What steps will reproduce the problem?
1. python doctests.py -v *.py


What is the expected output? What do you see instead?
Traceback (most recent call last):
  File "doctests.py", line 42, in <module>
    for name in sys.argv if name != "-v"]
ImportError: No module named *


What version of the product are you using? On what operating system?
python 2.5 
OS: windows xp

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Oct 2007 at 1:30

Error in utility function for Tic Tac Toe makes 'X' always win

What steps will reproduce the problem?
1. Run the following
from games import *

ttt = TicTacToe(3,3,3)
play_game(ttt,alphabeta_player,alphabeta_player)

2. Note that X always win, and that O seems to help X to win

What is the expected output? What do you see instead?
Expected is that there will always be a draw.

What version of the product are you using? On what operating system?
Ubuntu 10.10

Here is a patch to solve the problem.
Check which player is making the move and negate the utility when the player is 
O.

class TicTacToe(Game):
     ...
    def utility(self, state, player):
        "Return the value to X; 1 for win, -1 for loss, 0 otherwise."
        if player=="O":
            return -state.utility
        else:
            return state.utility



Original issue reported on code.google.com by [email protected] on 28 Feb 2011 at 6:55

bug in NearestNeighborLearner class in learning.py

"best" is described as a sorted list of (distance, example) pairs.
Yet when looping over "examples" and filling this list, we simply append
while the count is less than "k", which violates the sorting condition. We
only start sorting once the list is full and the new example has a distance
less than the top of the list.
As an example, take k=5, and imagine a dataset where the first four
instances are the furthest from the example we want to predict. Then
imagine that the fifth example happens to be the closest. Then when we
evaluate the rest of the examples, none will be added to the list "best"
since the condition on line 225 is never met.

Original issue reported on code.google.com by [email protected] on 13 Dec 2009 at 2:04

Cannot create EnvGUI (EnvCanvas missing)

What steps will reproduce the problem?
1. $  cd aima-python
2. $ python
3.  >>> import agents
4.  >>> v = VacuumEnvironment()
5. >>> e = EnvGUI(v)

What is the expected output?

Some Tkinkter window with the Environment

 What do you see instead?

An empty Tkinkter window and an error message at the repl:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rickard/devel/ArtificialIntelligence/aima/aima-python/agents.py", line 617, in 
__init__
    canvas = EnvCanvas(self, env, cellwidth, n)
NameError: global name 'EnvCanvas' is not defined

What version of the product are you using? On what operating system?

Svn revision 29 from Google Code on Mac OS X 10.4.11

Please provide any additional information below.

The commentary at the top of the agents.py file mentions the EnvCanvas class 
but the file 
doesn't contain a definition of it. Perhaps it is left as an excercise for the 
reader.. :-)

Original issue reported on code.google.com by [email protected] on 29 Jan 2008 at 1:57

We don't have that 'data' directory

If I try to run the tests

$ python doctests.py -v *.py

some fail because they can't find the data directory or the files in it.

These are the lines that originate the problems:

search.py:

BoggleFinder.wordlist = Wordlist("../data/wordlist")
(should be EN-text/wordlist)

text.py:

mandir = '../data/man/'
(should be MAN)

flatland = DataFile("flat11.txt").read() # there are two of these!
(should be EN-text/flatland.txt)

Finally, after replacing all the "../data/" with my "../aima-data/"
(checked out from the SVN repository), the tests were all successful (apart
from the one I mentioned in the other report).

--

Now I'll get back to try to understand the code, which is obviously much
more interesting. :-)

Thanks for releasing these programs with a free license, they're very
useful educational tools.

Best regards,
Matteo

Original issue reported on code.google.com by [email protected] on 1 Oct 2007 at 3:04

logic.to_cnf is not working properly

What steps will reproduce the problem?
import logic
logic.to_cnf("A | (B | (C | (D & E)))")

What is the expected output? What do you see instead?
expected: (D | A | B | C) & (E | A | B | C)
got this instead: (A | B | C | (D & E))
i.e. no effect except that that Nary correctly raised the '|' operations.

What version of the product are you using? On what operating system?
latest as of Oct 5th 2009
running on ubuntu linux, but it's likely  not related to my OS.

Please provide any additional information below.
The issue is likely in the distribute_and_over_or procedure.
to_cnf("A | (B | (C & D))") produces the correct output, so it's not
properly recursing.

Original issue reported on code.google.com by [email protected] on 6 Oct 2009 at 1:49

Policy iteration does not work

What steps will reproduce the problem?
1. Attempt to use the policy iteration algorithm

What is the expected output? What do you see instead?

Policy iteration should iterate several times before converging to a
solution. Instead, it converges after exactly one iteration.

What version of the product are you using? On what operating system?

The version posted on http://aima.cs.berkeley.edu/python/mdp.html, using
Python 2.6

Please provide any additional information below.

I've attached a fixed version of the file. The only line that changes
is 139:

U[s] = R(s) + gamma * sum([p * U[s1] for (p, s1) in T(s, pi[s])])




Original issue reported on code.google.com by [email protected] on 29 Apr 2010 at 5:54

Attachments:

Errors in NearestNeighborLearner

What steps will reproduce the problem?
Tried to use the learning.NearestNeighborLearner on the Sex Classification 
dataset from this Wikipedia article on Naive Bayes classifiers: 
http://en.wikipedia.org/wiki/Naive_Bayes_classifier#Sex_Classification

What is the expected output? What do you see instead?
Program wouldn't run due to bugs in the implementation of NNLearner

What version of the product are you using?
Bug exists in r30


Please provide any additional information below.
Here's my sample code:

import learning

examples = 
[[6,180,12,'male'],[5.92,190,11,'male'],[5.58,170,12,'male'],[5,100,6,'female'],
[5.5,150,8,'female'],[5.42,130,7,'female'],[5.75,150,9,'female']]

ds = learning.DataSet(examples)
nnl = learning.NearestNeighborLearner(2)
nnl.train(ds)
print nnl.predict([5.1,105,6.3])

And I would expect it to print 'female'.

I believe the following fixes should work:
old learning.py, lines 217 - 231

        else:
            ## Maintain a sorted list of (distance, example) pairs.
            ## For very large k, a PriorityQueue would be better
            best = [] 
            for e in examples:
                d = self.distance(e, example)
                if len(best) < k: 
                    e.append((d, e))
                elif d < best[-1][0]:
                    best[-1] = (d, e)
                    best.sort()
            return mode([e[self.dataset.target] for (d, e) in best])

    def distance(self, e1, e2):
        return mean_boolean_error(e1, e2)


new learning.py:

        else:
            ## Maintain a sorted list of (distance, example) pairs.
            ## For very large k, a PriorityQueue would be better
            best = [] 
            for e in self.dataset.examples:
                d = self.distance(e, example)
                if len(best) < self.k: 
                    best.append((d, e))
                elif d < best[-1][0]:
                    best[-1] = (d, e)
                    best.sort()
            return mode([e[self.dataset.target] for (d, e) in best])

    def distance(self, e1, e2):
        return mean_error(e1, e2)


Specifically:
1) changed 'examples' to self.dataset.examples. 
2) changed e.append((d,e)) to best.append((d, e))
3) and I could be wrong, but I believe you wanted mean_error, not 
mean_boolean_error in your distance function.

For the gender classification example, it seems to work great. Thanks!

Original issue reported on code.google.com by [email protected] on 19 Oct 2010 at 5:21

Bug in constructor for DataSet class within learning.py

Examples are checked via: map(self.check_example, self.examples). 
self.check_example makes reference to self.attrs and self.attrnames, both
of which have not been initialized prior to making the map call.

Moving the map call to the end of the constructor fixes the problem.  

Original issue reported on code.google.com by [email protected] on 6 Dec 2007 at 1:52

DefaultDict could front-end the native 2.5 version defaultdict

The collections.defaultdict class:

http://docs.python.org/library/collections.html#collections.defaultdict

could be used for Python 2.5+ rather than the method in utils.py:228

import collections
try: 
   collections.defaultdict ## set builtin introduced in 2.5
except NameError:
  class DefaultDict(dict):
  .
  .
  .




Original issue reported on code.google.com by [email protected] on 15 Sep 2009 at 3:00

TicTacToe games utility method is incorrect

Firstly it does not have a player argument so none of the search algorithms 
work on it.

    def utility(self, state, player):
        "Return the value to X; 1 for win, -1 for loss, 0 otherwise."
        if player == 'X':
            return state.utility
        if player == 'O':
            return -state.utility

Does seem to work.

Tom Hall

Original issue reported on code.google.com by [email protected] on 11 Aug 2011 at 6:55

Misleading comment in MDP class

The following definition is present in the MDP class:

   def T(self,state, action): 
        """Transition model.  From a state and an action, return a list
        of (result-state, probability) pairs."""

the value iteration procedure, though, expects the transition model to return a 
list of (probability,result-state) pairs. I haven't looked at what other 
algorithms might be expecting.

Original issue reported on code.google.com by [email protected] on 21 Apr 2011 at 6:26

Unit Tests Fail 'out-of-the-box'

What steps will reproduce the problem?
1. Download and install code from /trunk and get test /data:

 svn checkout http://aima-python.googlecode.com/svn/trunk/ python svn checkout http://aima-data.googlecode.com/svn/trunk/ data

2. Run the unit tests from the shell: $ python doctests.py -v *.py
  ...
  /python/csp.py
  Failed example: len(min_conflicts(NQueensCSP(8)))
  ...

3. Run the code analysis tool from the shell: $ pylint csp.py
  ...

Messages shows lots of errors. 35 occurrences of error id E1101 - 
http://www.logilab.org/card/pylintfeatures - Used when a variable is accessed 
for an unexistent member. 1 occurrence of error id E1121 - Used when a function 
call passes too many positional arguments.

4. Download and installed code snapshot (instead of taking directly from /trunk 
which is usually under active - unstable - development!) to see if that is more 
stable - 
http://code.google.com/p/aima-python/downloads/detail?name=aima-python.2007.06.1
5.zip

5. Download and installed data snapshot (and not from data /trunk) just in case 
this test data is meant to be stable against python.2001.06.15.zip code base - 
http://code.google.com/p/aima-data/downloads/detail?name=aima-data.2008.08.24.zi
p&can=2&q=

6. Run test cases relating to these 2 snapshots above: /python.2007.06.15$ 
python doctests.py -v *.py ... Get lots of different errors (e.g. missing file 
../data/wordlist), so this snapshot does not pass the test cases either.

7. Also ran the above snapshot test against latest trunk /data and same errors.

What is the expected output? What do you see instead?
The last line printed should be "Test passed."

What version of the product are you using? On what operating system?
1. Latest code & data from respective /trunks, Python 2.7.1+, Ubuntu 11.04


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 25 Aug 2011 at 3:07

6 Tests failing in latest svn download of data and code

What steps will reproduce the problem?
1. For failing test in mdp.py, the doctest output was wrong. Fixed the doctest 
output.
2. For 5 failing tests for the stochastic processes, the tests were failing 
because the expected output from ignoring the results was "Nothing" but the 
tests were still printing out results. This was because the test 
'present_results' was actually printing to standard output and the "ignore" 
method does not work in suppressing the output.
The fix was to test the 'query' method instead of the 'present_results' method.

What is the expected output? What do you see instead?
Expected: All tests should pass
Saw: 6 Tests failed - one in mdp.py and 5 in text.py

What version of the product are you using? On what operating system?
Using the latest from svn as of 07/24/2010.
OS: Ubuntu 10.04

Please provide any additional information below.
The files with fixes are attached below.

Original issue reported on code.google.com by [email protected] on 25 Jul 2010 at 6:02

Attachments:

games.py line 121 missing argument in call to legal_moves method

What steps will reproduce the problem?
1. call random_player(game,state) in games.py
2.
3.

What is the expected output? What do you see instead?

Expected: A valid move returned

Unexpected Outcome: 
Traceback (most recent call last):
  File "<pyshell#28>", line 1, in <module>
    games.random_player(game,gamestate)
  File "/aima-python-read-only/games.py", line 121, in random_player
    return random.choice(game.legal_moves(state))
TypeError: legal_moves() takes exactly 2 arguments (1 given)


What version of the product are you using? On what operating system?

Py 2.5.2 /linux latest aima code from svn

Please provide any additional information below.

To fix change line 121 
from:
return random.choice(game.legal_moves())
to:
return random.choice(game.legal_moves(state))



Original issue reported on code.google.com by [email protected] on 30 Jun 2008 at 1:55

conjuncts() and disjuncts() need to be recursive

I was playing with the Criminal(West) example and the new fol_bc_ask()
stuff, couldn't get it to work unless I changed conjuncts() as follows:

def conjuncts(s):
    if isinstance(s, Expr) and s.op == '&':
        r = []
        for arg in s.args:
            r.extend (conjuncts (arg))
        return r
    else:
        return [s]

Without this change, conjuncts() will do this:
>>> conjuncts (sar.args[0])
[((American(v_1) & Weapon(v_2)) & Sells(v_1, v_2, v_3)), Hostile(v_3)]

Original issue reported on code.google.com by [email protected] on 2 Mar 2009 at 6:53

ATTENTION: Download of aima-data.2008.08.24.zip appears to contain Worm

What steps will reproduce the problem?

1. download of aima-data.2008.08.24.zip
2. scan with ClamTK

What is the expected output? What do you see instead?

Expect no virus.  Instead contains - Worm.Sircam

What version of the product are you using? On what operating system?

Found using Ubuntu 10.04.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 17 May 2010 at 2:22

Attachments:

Logic expression does not support not-equal comparison

What steps will reproduce the problem?

>>> from logic import *
>>> expr("a") == expr("a")
True
>>> expr("a") != expr("a")
True
>>>


What is the expected output? What do you see instead?

The expected output is that  expr("a") != expr("a")  will return False

What version of the product are you using? On what operating system?

Tested on pyhton 2.6.3 and 2.5.2 on linux

Please provide any additional information below.

Easy fix - add this method to the Expr class:

  def __ne__(self, other):
        return not self.__eq__(other)

Original issue reported on code.google.com by [email protected] on 3 Dec 2009 at 1:15

Several bugs in CSP.py, patch included

Reproduce:
$ python
>>> from csp import *
>>> backtracking_search(australia, mcv=True, fc=True)
-> Results in wrong coloring 

Several issues:
- Forward checking and Arc Consistency are severely broken. The most severe
issue is in line 86, where information about pruned domains from previous
steps is wrongly discarded.
- Most constrained variable-heuristic has it backwards and orders the least
constrained variable first
- Least constraining value-heuristic fails to compile on modern python
- The map of USA is wrong (New York adjacent to California), some borders
missing

The included patch fixes the described issues plus adds
- The map of France by Regions
- Formulation of the Sudoku-Problem
- Some trivial testing code

Otherwise great book!

Original issue reported on code.google.com by [email protected] on 6 Jul 2009 at 12:17

Attachments:

Neighbors for NY are incorrect for USA map coloring problem

What steps will reproduce the problem?
1. Open file: http://aima.cs.berkeley.edu/python/csp.py
2. Look at data for NY: "NY: VT MA CA NJ"
3. Notice that the third neighbor should be CT, not CA

What is the expected output? What do you see instead?
As above.

What version of the product are you using? On what operating system?
Latest from web.

Please provide any additional information below.
N/A

Original issue reported on code.google.com by [email protected] on 12 Nov 2007 at 9:47

nlp.py: E0 grammar missing Name in NP

just a minor typo,

line 49: NP = 'Pronoun | Noun | Article Noun | Digit Digit | NP PP | NP 
RelClause',


Original issue reported on code.google.com by eriksilkensen on 11 Oct 2010 at 5:38

'sorted' from python 2.4 or 2.5 makes test on 'utils.histogram' fail

1) What steps will reproduce the problem?

$ python2.4 doctests.py -v utils.py

or

$ python2.5 doctests.py -v utils.py

2) What is the expected output? What do you see instead?

Failed example:
    histogram(vals, 1) 
Expected:
    [(200, 3), (110, 2), (160, 2), (220, 1), (100, 1)]
Got:
    [(200, 3), (160, 2), (110, 2), (100, 1), (220, 1)]

3) What version of the product are you using? On what operating system?

* Code from SVN repository.
* Debian GNU/Linux (Sid, up-to-date).

4) Please provide any additional information below.

It looks like python's sorted in 2.4 or 2.5 doesn't work exactly as the one
supplied (but I can't try that because I haven't got 2.3, and on 2.4 it
doesn't work).

I'm sure this is not a bug, but maybe you're interested in having
successful tests also on python >= 2.4.

Sorry for such a useless report, otherwise. :-)

Original issue reported on code.google.com by [email protected] on 1 Oct 2007 at 2:23

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.