aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
7.97k stars 3.76k forks source link

Linear Learner Section of learning.ipynb Doesn't Work. #1254

Open aidan-le-beard opened 2 years ago

aidan-le-beard commented 2 years ago

The dot product from command "y = np.dot(w, x)" is resulting in the error: ValueError: shapes (5,) and (6,) not aligned: 5 (dim 0) != 6 (dim 0)

I can't figure out how to fix this for the life of me, any advice?


ValueError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_18692/3598892250.py in 2 iris.classes_to_numbers() 3 ----> 4 linear_learner = LinearLearner(iris) 5 print(linear_learner([5, 3, 1, 0.1]))

~\aima-python\learning.py in LinearLearner(dataset, learning_rate, epochs) 528 for example in examples: 529 x = [1] + example --> 530 y = np.dot(w, x) 531 t = example[idx_t] 532 err.append(t - y)

<__array_function__ internals> in dot(*args, **kwargs) ValueError: shapes (5,) and (6,) not aligned: 5 (dim 0) != 6 (dim 0)