towhee.functional.mixins.dataset.DatasetMixin¶
- class towhee.functional.mixins.dataset.DatasetMixin[source]¶
Bases:
object
Mixin for dealing with dataset
Methods
filter_data
generate a file list with pattern
random_sample
read_csv
read_json
load files from url/path.
Split DataCollection to train and test data.
Save dc as a csv file.
- classmethod read_zip(url, pattern, mode='r')[source]¶
load files from url/path.
- Parameters:
zip_src (Union[str, path]) – The path leads to the image.
pattern (str) – The filename pattern to extract.
mode (str) – file open mode.
- Returns:
The file handler for file in the zip file.
- Return type:
(File)
- split_train_test(size: list = [0.9, 0.1], **kws)[source]¶
Split DataCollection to train and test data.
- Parameters:
size (list) – The size of the train and test.
Examples:
>>> from towhee.functional import DataCollection >>> dc = DataCollection.range(10) >>> train, test = dc.split_train_test(shuffle=False) >>> train.to_list() [0, 1, 2, 3, 4, 5, 6, 7, 8] >>> test.to_list() [9]