예제 #1
0
    def test_store_load(self):
        x = np.array([[1, 0, 0], [0, 1, 1], [1, 1, 1], [0, 1, 1]])
        y = {"default": np.array(['a', "b", "c", "a"])}

        svm = SVM()
        svm._fit(sparse.csr_matrix(x), y["default"])

        path = EnvironmentSettings.root_path / "test/tmp/store_load_sklearn/"
        details_path = EnvironmentSettings.root_path / "test/tmp/store_load_sklearn/details.yaml"

        svm.store(path=path, details_path=details_path)

        svm2 = SVM()
        svm2.load(path=path, details_path=details_path)

        shutil.rmtree(path)
예제 #2
0
    def test_load(self):
        x = np.array([[1, 0, 0], [0, 1, 1], [1, 1, 1], [0, 1, 1]])
        y = {"default": np.array([1, 0, 2, 0])}

        svm = SVM()
        svm.fit(EncodedData(x, y), 'default')

        path = EnvironmentSettings.tmp_test_path / "my_svm2/"
        PathBuilder.build(path)

        with open(path / "svm.pickle", "wb") as file:
            pickle.dump(svm.get_model(), file)

        svm2 = SVM()
        svm2.load(path)

        self.assertTrue(isinstance(svm2.get_model(), SVC))

        shutil.rmtree(path)