def test_generate_subdataset(self, method="train_test", by=0.8): """ Creates a Project and a Dataset and links each other. Then creates a SubDataset out of the created Dataset. The subdataset are created using method and by paramenters Asserts ------- - Indicies are not None """ Project(path=self.path_to_test_dir, name=self.aux_project_name) ds = Dataset.read_file(path=self.path_to_dataset) ds.save() sbds = SubDataset(dataset=ds, method=method, by=by) self.assertIsNotNone(sbds.indices) return sbds
def test_create_dataset(self): """ Takes a dataset file and constructs a new dataset Asserts ------- - If the object created is an instance of a Dataset object - If the datasource attribute is an instance of a FileDataset object Returns ------- A Dataset object instance created from the dataset file """ Project(name=self.aux_project_name, path=self.path_to_test_dir) ds = Dataset.read_file(path=self.path_to_dataset, first_line_heading=False) self.assertIsInstance(ds, Dataset) self.assertIsInstance(ds.datasource, FileDatasource) return ds
from driftai.data.dataset import Dataset from driftai.project import Project from driftai.approach import Approach from driftai import set_project_path ds = Dataset.from_dir( r"C:\cygwin64\home\fcgr\code\driftai\examples\mnst_digit_classification_old\data" ) proj_path = r"C:\cygwin64\home\fcgr\code\driftai\test\my_tests" proj_name = "a" if Path("{}\{}".format(proj_path, proj_name)).exists(): shutil.rmtree(str(Path("{}\{}".format(proj_path, proj_name)).absolute())) p = Project(name="a", path=r"C:\cygwin64\home\fcgr\code\driftai\test\my_tests") set_project_path(p.path) info = ds.get_info() ds.save() sbs = ds.generate_subdataset(method="k_fold", by=5) sbs.save() from PIL import Image import numpy as np #tr_data = sbs.get_train_data("A", loader=lambda x: np.asarray(Image.open(x)).reshape(-1)) #ts_data = sbs.get_test_data("A", loader=lambda x: np.asarray(Image.open(x))) a = Approach(project=p, name="my_approach", subdataset=sbs)
def test_automatically_detect_regression(self): Project(name=self.aux_project_name, path=self.path_to_test_dir) ds = Dataset.read_file("test/resources/housing.csv", label="median_house_value") self.assertEqual(ds.problem_type, "regression")
def test_automatically_detect_binary_clf(self): Project(name=self.aux_project_name, path=self.path_to_test_dir) ds = Dataset.read_file("test/resources/titanic.csv", label="Survived") self.assertEqual(ds.problem_type, "binary_clf")
def test_automatically_detect_clf(self): Project(name=self.aux_project_name, path=self.path_to_test_dir) ds = Dataset.read_file("test/resources/Iris.csv") self.assertEqual(ds.problem_type, "clf")