Skip to content

Commit 6252e28

Browse files
antmarakisnorvig
authored andcommitted
neural net tests (aimacode#630)
1 parent 01e4fcd commit 6252e28

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tests/test_learning.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def test_decision_tree_learner():
166166

167167

168168
def test_random_forest():
169-
random.seed("aima-python")
170169
iris = DataSet(name="iris")
171170
rF = RandomForest(iris)
172171
assert rF([5, 3, 1, 0.1]) == "setosa"
@@ -175,19 +174,21 @@ def test_random_forest():
175174

176175

177176
def test_neural_network_learner():
178-
random.seed("aima-python")
179177
iris = DataSet(name="iris")
180178
classes = ["setosa", "versicolor", "virginica"]
181179
iris.classes_to_numbers(classes)
182180
nNL = NeuralNetLearner(iris, [5], 0.15, 75)
183-
tests = [([5, 3, 1, 0.1], 0),
184-
([5, 3.5, 1, 0], 0),
185-
([6, 3, 4, 1.1], 1),
186-
([6, 2, 3.5, 1], 1),
187-
([7.5, 4, 6, 2], 2),
188-
([7, 3, 6, 2.5], 2)]
189-
assert grade_learner(nNL, tests) >= 2/3
190-
assert err_ratio(nNL, iris) < 0.25
181+
tests = [([5.0, 3.1, 0.9, 0.1], 0),
182+
([5.1, 3.5, 1.0, 0.0], 0),
183+
([4.9, 3.3, 1.1, 0.1], 0),
184+
([6.0, 3.0, 4.0, 1.1], 1),
185+
([6.1, 2.2, 3.5, 1.0], 1),
186+
([5.9, 2.5, 3.3, 1.1], 1),
187+
([7.5, 4.1, 6.2, 2.3], 2),
188+
([7.3, 4.0, 6.1, 2.4], 2),
189+
([7.0, 3.3, 6.1, 2.5], 2)]
190+
assert grade_learner(nNL, tests) >= 1/3
191+
assert err_ratio(nNL, iris) < 0.2
191192

192193

193194
def test_perceptron():

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy