def prepare_dataset(self): self.__dataset = RandomPointDatasetGenerator( classifier=PointClassifier(classes=self.__classes), generator=RandomListGenerator( generator=RandomValueGenerator(),) ).commit_classified(self.__size) return RandomPointDatasetSplitter(self.__dataset).commit(ratio=self.__ratio)
def test_point_database_splitter_10000_samples(self): x_train, x_test, y_train, y_test = RandomPointDatasetSplitter( dataset=RandomPointDatasetGenerator(generator=RandomListGenerator( generator=RandomValueGenerator()), classifier=PointClassifier(12)) .commit_classified(10000)).commit(.7) self.assertAlmostEqual(7000, len(x_train), delta=100) self.assertAlmostEqual(7000, len(y_train), delta=100) self.assertAlmostEqual(3000, len(x_test), delta=100) self.assertAlmostEqual(3000, len(y_test), delta=100)
def test_point_dataset_generator_from_minus_5_to_5(self) -> None: for point in RandomPointDatasetGenerator( generator=RandomListGenerator( generator=RandomValueGenerator(-5, 5)), classifier=PointClassifier(12)).commit_classified(1000): self.assertAlmostEqual(0, point[0][0], delta=5) self.assertAlmostEqual(0, point[0][1], delta=5) self.assertLess(point[0][0], 5, 'Point X coordinate cannot be greater than 5!') self.assertGreater(point[0][0], -5, 'Point X coordinate cannot be less than -5!') self.assertLess(point[0][1], 5, 'Point Y coordinate cannot be greater than 5!') self.assertGreater(point[0][1], -5, 'Point Y coordinate cannot be less than -5!') return None
def test_point_classifier_plane_1_class_1(self) -> None: point: Point = (0.25, 0.25) self.assertEqual(2, PointClassifier(12).commit(point)) return None
def test_point_classifier_plane_4_class_12(self) -> None: point: Point = (0.85, -0.15) self.assertEqual(12, PointClassifier(12).commit(point)) return None
def test_point_classifier_plane_3_class_9(self) -> None: point: Point = (-0.25, -0.8) self.assertEqual(9, PointClassifier(12).commit(point)) return None
def test_point_classifier_plane_2_class_4(self) -> None: point: Point = (-0.15, 0.8) self.assertEqual(4, PointClassifier(12).commit(point)) return None
def test_point_classifier_plane_1_class_3(self) -> None: point: Point = (0.16, 0.86) self.assertEqual(3, PointClassifier(12).commit(point)) return None