def test_can_load_with_model(self, classifier: Model, tmp_path: pathlib.Path): storage = FileStorage(tmp_path) expected_file = classifier.save_estimator(storage) assert expected_file.exists() loaded_file = classifier.load_estimator(expected_file, storage=storage) assert isinstance(loaded_file, Model) storage_context = FileStorage(tmp_path) context_loaded_file = classifier.load_estimator( expected_file, storage=storage_context) assert isinstance(context_loaded_file, Model)
def test_save_estimator_uses_default_storage_if_no_storage_is_passed( self, tmp_path: pathlib.Path, classifier: Model): classifier.config.ESTIMATOR_DIR = tmp_path classifier.save_estimator() models = classifier.config.default_storage.get_list() assert len(models) == 1 new_classifier = Model.load_estimator(models[0]) assert (classifier.estimator.get_params() == new_classifier.estimator.get_params())
def test_regression_model_can_be_saved(self, classifier: Model, tmp_path: pathlib.Path, train_iris_dataset): classifier.score_estimator(train_iris_dataset) load_storage = FileStorage(tmp_path) storage = FileStorage(tmp_path) saved_model_path = classifier.save_estimator(storage) assert saved_model_path.exists() loaded_model = classifier.load_estimator(saved_model_path, storage=load_storage) assert loaded_model.estimator.get_params( ) == classifier.estimator.get_params()