Esempio n. 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)
Esempio n. 2
0
    def test_store(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/storesklearn/"

        svm.store(path)
        self.assertTrue(os.path.isfile(path / "svm.pickle"))

        with open(path / "svm.pickle", "rb") as file:
            svm2 = pickle.load(file)

        self.assertTrue(isinstance(svm2, SVC))

        shutil.rmtree(path)