GithubHelp home page GithubHelp logo

yasufumy / pipelib Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 106 KB

:zap:A minimal data pipeline library for Python

License: MIT License

Python 99.07% Makefile 0.93%
python machine-learning dataset

pipelib's Introduction

pipelib's People

Contributors

yasufumy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pipelib's Issues

Add Dataset.unzip

def unzip(self):
    def f(datasets):
        x = datasets.first()
        assert any(isinstance(x, t) for t in (list, tuple))

        dataset, *others = zip(*datasets)
        return (Dataset(dataset),) + tuple(Dataset(other) for other in others)
   return PipelinedDataset(self, f)

But this is eager evaluation

Add a concat method

  • add Dataset.concat
class Dataset:
    def concat(self, *others):
        def f(dataset):
            yield from chain(dataset, *others)
    return PipelinedDataset(self, f)

Add a zip method

class Dataset:
    def zip(self, *others):
        def f(dataset):
            yield from zip(dataset, *others)
        return PipelinedDataset(self, f)

Refactoring Dataset.shuffle

def f(dataset):
    iterator = iter(dataset)
    for chunk in takewhile(bool, (list(islice(iterator, shuffle_size)) for _ in count(0))):
        random.shuffle(chunk)
        yield from chunk

Dataset.split

Do we need Dataset.split?

>>> data = Dataset(range(100))
>>> train, test = data.split(ratio=[0.8, 0.2])
>>> len(train.all())
80
>>> len(test.all())
20

Fix bug in Dataset.save

class Dataset:
    def save(self, filename):
        evaluated_dataset = list(self)
        with open(filename, 'wb') as f:
            pickle.dump(evaluated_dataset, f)
        return EvaluatedDataset(evaluated_dataset)

class EvaluatedDataset(PipelinedDataset):
    ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.