Пример #1
0
    def load_from_data(cls, data):
        """
        Load approach from JSON coming from TinyDB

        Parameters
        ----------
        data: dict
            Dict containing the approach instance summary

        Returns
        --------
        Approach
            Approach instance generated from JSON data
        """
        from driftai.project import Project
        from driftai.db import Collections

        subdataset = Collections.subdatasets().get(data["subdataset"])
        a = Approach(project=Project.load(),
                     name=data["name"],
                     subdataset=subdataset,
                     path=str(Path(data["path"]).absolute()),
                     creation_date=data["creation_date"])

        a.runs = [
            Run.load_from_data(r, subdataset=subdataset) for r in data["runs"]
        ]

        return a
Пример #2
0
    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
Пример #3
0
 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
Пример #4
0
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)
Пример #5
0
 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")
Пример #6
0
 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")
Пример #7
0
 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")