Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_NNGeneral.ExampleManagerTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_adding_examples
def test_partioning_examples

Public Attributes

 num_examples
 examples

Detailed Description

Tests to make sure the example manager is working properly.

Definition at line 41 of file test_NNGeneral.py.


Member Function Documentation

Definition at line 44 of file test_NNGeneral.py.

00044 
00045     def setUp(self):
00046         self.num_examples = 500
00047         self.examples = []
00048         for make_example in range(self.num_examples):
00049             inputs = []
00050             for input_make in range(3):
00051                 inputs.append(random.randrange(1, 7))
00052             outputs = [random.randrange(1, 7)]
00053             self.examples.append(TrainingExample(inputs, outputs))

Make sure test examples are added properly.

Definition at line 54 of file test_NNGeneral.py.

00054 
00055     def test_adding_examples(self):
00056         """Make sure test examples are added properly.
00057         """
00058         manager = ExampleManager()
00059 
00060         # figure out the expected number of examples in each category
00061         expected_train = manager.training_percent * self.num_examples
00062         expected_validation = manager.validation_percent * self.num_examples
00063         expected_test = self.num_examples - expected_train \
00064                         - expected_validation
00065 
00066         manager.add_examples(self.examples)
00067 
00068         for expect, actual in [(expected_train, len(manager.train_examples)),
00069                                (expected_validation,
00070                                 len(manager.validation_examples)),
00071                                (expected_test, len(manager.test_examples))]:
00072             
00073             wrong_percent = abs(expect - actual) / self.num_examples
00074             assert wrong_percent < .1, \
00075                    "Deviation in how examples were added, expect %s, got %s" \
00076                    % (expect, actual)
        
Test that we can change how to partition the test examples.

Definition at line 77 of file test_NNGeneral.py.

00077 
00078     def test_partioning_examples(self):
00079         """Test that we can change how to partition the test examples.
00080         """
00081         manager = ExampleManager(0, 0)
00082         manager.add_examples(self.examples)
00083         assert len(manager.test_examples) == self.num_examples, \
00084                "Did not partion correctly to test_examples."
00085 
00086         manager = ExampleManager(1.0, 0)
00087         manager.add_examples(self.examples)
00088         assert len(manager.train_examples) == self.num_examples, \
00089                "Did not partition correctly to train_examples."
00090 
00091         manager = ExampleManager(0, 1.0)
00092         manager.add_examples(self.examples)
00093         assert len(manager.validation_examples) == self.num_examples, \
00094                "Did not partition correctly to validation_examples."


Member Data Documentation

Definition at line 46 of file test_NNGeneral.py.

Definition at line 45 of file test_NNGeneral.py.


The documentation for this class was generated from the following file: